{"action":"created","issue":{"url":"https://api.github.com/repos/gterzian/Python-Parallel-Collections/issues/3","labels_url":"https://api.github.com/repos/gterzian/Python-Parallel-Collections/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/gterzian/Python-Parallel-Collections/issues/3/comments","events_url":"https://api.github.com/repos/gterzian/Python-Parallel-Collections/issues/3/events","html_url":"https://github.com/gterzian/Python-Parallel-Collections/pull/3","id":61083223,"number":3,"title":"ParallelGen.filter() should adopt the same behavior with builtin-filter","user":{"login":"kogecoo","id":4001732,"avatar_url":"https://avatars.githubusercontent.com/u/4001732?v=3","gravatar_id":"","url":"https://api.github.com/users/kogecoo","html_url":"https://github.com/kogecoo","followers_url":"https://api.github.com/users/kogecoo/followers","following_url":"https://api.github.com/users/kogecoo/following{/other_user}","gists_url":"https://api.github.com/users/kogecoo/gists{/gist_id}","starred_url":"https://api.github.com/users/kogecoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogecoo/subscriptions","organizations_url":"https://api.github.com/users/kogecoo/orgs","repos_url":"https://api.github.com/users/kogecoo/repos","events_url":"https://api.github.com/users/kogecoo/events{/privacy}","received_events_url":"https://api.github.com/users/kogecoo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-13T14:53:36Z","updated_at":"2015-03-14T08:43:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/gterzian/Python-Parallel-Collections/pulls/3","html_url":"https://github.com/gterzian/Python-Parallel-Collections/pull/3","diff_url":"https://github.com/gterzian/Python-Parallel-Collections/pull/3.diff","patch_url":"https://github.com/gterzian/Python-Parallel-Collections/pull/3.patch"},"body":" As I mentioned in an earlier comment in the [Pull Request #2](https://github.com/gterzian/Python-Parallel-Collections/pull/2), I have a opinion that it should behaves same with Python builtin-filter. For clarify the \"same behavior\", I dived into the source code of filter_next() at the [bltinmodule.c](https://github.com/python/cpython/blob/master/Python/bltinmodule.c) in the [CPython](https://github.com/python/cpython/) repository.\r\n\r\n It seems to be interpreted as follows:\r\n \r\n1. At first, function object which passed to filter method is None or bool(), it simply behaves filter which passed bool() method.\r\n\r\n2. Otherwise, evaluate `bool(func(item))`. (The result is stored `ok` variable.).\r\n\r\n3. If the value of `ok` stands for True, filter method returns `item`. Notice that it allows any Python object as item, including `None`.\r\n\r\n4. If the value of `ok` stands for False, filter method return `null` - It means nothing (including `None`) is returned in Python world.\r\n\r\n\r\nSo back to the Python-Parallel-Collections, the differences between builtin filter and ParallelGen.filter() are only two:\r\n\r\n* Whether it accepts None as evaluate function. (regarding 1.)\r\n\r\n```\r\nxs = [0, 1, 2, 3, 4]\r\n \r\nfilter(None, xs)   # returns [1, 2, 3, 4]\r\n\r\nlist(parallel(xs).filter(None))   # raises TypeError: 'NoneType' object \r\n\r\n```\r\n\r\n* Whether it can be handle the None element in a sequence. (regarding 2.-4.)\r\n\r\n```\r\ndef isNone(x):\r\n    return x is None\r\n\r\nxs = [0, 1, 2, None, 3, 4]\r\n\r\nfilter(isNone, xs)   # returns [None]\r\n\r\nlist(parallel(xs).filter(isNone))   # returns []\r\n\r\n```\r\n\r\n I guess there are many approach to tackle this, but I propose a simple one of it which requires a small-difference against the current code.\r\n\r\n This is just a proposal, and moreover, I have no confidence in the naming of test functions (I'm not a native in English ;-<).\r\nSo if you feel it has a problem, feel free to request me to rewrite, or of course you could make another fix based on this modification if you'd like to."},"comment":{"url":"https://api.github.com/repos/gterzian/Python-Parallel-Collections/issues/comments/80158373","html_url":"https://github.com/gterzian/Python-Parallel-Collections/pull/3#issuecomment-80158373","issue_url":"https://api.github.com/repos/gterzian/Python-Parallel-Collections/issues/3","id":80158373,"user":{"login":"gterzian","id":2792687,"avatar_url":"https://avatars.githubusercontent.com/u/2792687?v=3","gravatar_id":"","url":"https://api.github.com/users/gterzian","html_url":"https://github.com/gterzian","followers_url":"https://api.github.com/users/gterzian/followers","following_url":"https://api.github.com/users/gterzian/following{/other_user}","gists_url":"https://api.github.com/users/gterzian/gists{/gist_id}","starred_url":"https://api.github.com/users/gterzian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gterzian/subscriptions","organizations_url":"https://api.github.com/users/gterzian/orgs","repos_url":"https://api.github.com/users/gterzian/repos","events_url":"https://api.github.com/users/gterzian/events{/privacy}","received_events_url":"https://api.github.com/users/gterzian/received_events","type":"User","site_admin":false},"created_at":"2015-03-14T08:43:31Z","updated_at":"2015-03-14T08:43:31Z","body":"@kogecoo Thank you for the contribution!\r\n\r\n I think it looks very good, including the english naming of test functions :smile: \r\n\r\nPerhaps you could add a little paragraph to the README explaining the change and rationale? Just in case some people got used to the previous behavior. I'll release this as version 1.2, so you could add a note at the top with the title `API changes in 1.2`. \r\n\r\nLooks like you're right about the coverage and multiple processes. \r\n\r\n"}}