{"action":"opened","issue":{"url":"https://api.github.com/repos/pytoolz/toolz/issues/309","repository_url":"https://api.github.com/repos/pytoolz/toolz","labels_url":"https://api.github.com/repos/pytoolz/toolz/issues/309/labels{/name}","comments_url":"https://api.github.com/repos/pytoolz/toolz/issues/309/comments","events_url":"https://api.github.com/repos/pytoolz/toolz/issues/309/events","html_url":"https://github.com/pytoolz/toolz/issues/309","id":157964646,"number":309,"title":"Is checks for `no_default` fail if string is pickled","user":{"login":"jcrist","id":2783717,"avatar_url":"https://avatars.githubusercontent.com/u/2783717?v=3","gravatar_id":"","url":"https://api.github.com/users/jcrist","html_url":"https://github.com/jcrist","followers_url":"https://api.github.com/users/jcrist/followers","following_url":"https://api.github.com/users/jcrist/following{/other_user}","gists_url":"https://api.github.com/users/jcrist/gists{/gist_id}","starred_url":"https://api.github.com/users/jcrist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcrist/subscriptions","organizations_url":"https://api.github.com/users/jcrist/orgs","repos_url":"https://api.github.com/users/jcrist/repos","events_url":"https://api.github.com/users/jcrist/events{/privacy}","received_events_url":"https://api.github.com/users/jcrist/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-01T17:35:27Z","updated_at":"2016-06-01T17:35:27Z","closed_at":null,"body":"Opening this for discussion, as the solution may be just \"don't do that\". Currently, many functions take an optional keyword argument with a default of `__no__default__`. This is checked for comparison with `is`, which in general is True if the strings are equal, and is quite fast. This fails however if the default argument is serialized using pickle:\r\n\r\n```python\r\nIn [1]: from pickle import dumps, loads\r\n\r\nIn [2]: s = '__no__default__'\r\n\r\nIn [3]: s is s\r\nOut[3]: True\r\n\r\nIn [4]: s2 = loads(dumps(s))\r\n\r\nIn [5]: s is s2\r\nOut[5]: False\r\n```\r\n\r\nThis can cause problems in dask (or at least makes the graphs a bit more complicated), as we can't just transparently pass the string through as an argument. One solution might be to use `==` instead, although this incurs a minor speed penalty:\r\n\r\n```python\r\nIn [6]: %timeit s is s\r\n10000000 loops, best of 3: 50.2 ns per loop\r\n\r\nIn [7]: %timeit s == s\r\n10000000 loops, best of 3: 57.5 ns per loop\r\n\r\nIn [8]: %timeit s == s2\r\n10000000 loops, best of 3: 59 ns per loop\r\n```\r\n\r\nThese numbers are different for python 3:\r\n\r\n```python\r\nIn [6]: %timeit s is s\r\n10000000 loops, best of 3: 45.2 ns per loop\r\n\r\nIn [7]: %timeit s == s\r\n10000000 loops, best of 3: 52.9 ns per loop\r\n\r\nIn [8]: %timeit s == s2\r\n10000000 loops, best of 3: 62.2 ns per loop\r\n```"}}
{"actor":{"display_login":"jcrist"}}