{"action":"created","issue":{"url":"https://api.github.com/repos/numba/numba/issues/1681","repository_url":"https://api.github.com/repos/numba/numba","labels_url":"https://api.github.com/repos/numba/numba/issues/1681/labels{/name}","comments_url":"https://api.github.com/repos/numba/numba/issues/1681/comments","events_url":"https://api.github.com/repos/numba/numba/issues/1681/events","html_url":"https://github.com/numba/numba/issues/1681","id":130212812,"number":1681,"title":"caching functions taking a JIT class","user":{"login":"chris-b1","id":1924092,"avatar_url":"https://avatars.githubusercontent.com/u/1924092?v=3","gravatar_id":"","url":"https://api.github.com/users/chris-b1","html_url":"https://github.com/chris-b1","followers_url":"https://api.github.com/users/chris-b1/followers","following_url":"https://api.github.com/users/chris-b1/following{/other_user}","gists_url":"https://api.github.com/users/chris-b1/gists{/gist_id}","starred_url":"https://api.github.com/users/chris-b1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chris-b1/subscriptions","organizations_url":"https://api.github.com/users/chris-b1/orgs","repos_url":"https://api.github.com/users/chris-b1/repos","events_url":"https://api.github.com/users/chris-b1/events{/privacy}","received_events_url":"https://api.github.com/users/chris-b1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-31T23:28:47Z","updated_at":"2016-03-24T17:43:12Z","closed_at":null,"body":"\r\n\r\n```python\r\nIn [71]: import numba as nb\r\nIn [72]: nb.__version__\r\nOut[72]: '0.23.1'\r\n\r\nIn [73]: @nb.jitclass([\r\n    ...: ('value', nb.float64[:])\r\n    ...: ])\r\n    ...: class Container(object):\r\n    ...:     def __init__(self, value):\r\n    ...:         self.value = value\r\n\r\nIn [74]: @nb.jit(nopython=True)\r\n    ...: def fun(a, container):\r\n    ...:     return a + container.value[0]\r\n\r\nIn [75]: c = Container(np.array([1,2.4,3]))\r\n\r\nIn [77]: fun(1, c)\r\nOut[77]: 2.0\r\n\r\nIn [78]: @nb.jit(nopython=True, cache=True)\r\n    ...: def fun(a, container):\r\n    ...:     return a + container.value[0]\r\n\r\nIn [79]: fun(1, c)\r\n---------------------------------------------------------------------------\r\nPicklingError                             Traceback (most recent call last)\r\n<ipython-input-79-53b1add910cd> in <module>()\r\n----> 1 fun(1, c)\r\n\r\nC:\\Users\\Chris\\Anaconda\\lib\\site-packages\\numba\\dispatcher.pyc in _compile_for_args(self, *args, **kws)\r\n    169         assert not kws\r\n    170         sig = tuple([self.typeof_pyval(a) for a in args])\r\n--> 171         return self.compile(sig)\r\n    172 \r\n    173     def inspect_llvm(self, signature=None):\r\n\r\nC:\\Users\\Chris\\Anaconda\\lib\\site-packages\\numba\\dispatcher.pyc in compile(self, sig)\r\n    354 \r\n    355             self.add_overload(cres)\r\n--> 356             self._cache.save_overload(sig, cres)\r\n    357             return cres.entry_point\r\n    358 \r\n\r\nC:\\Users\\Chris\\Anaconda\\lib\\site-packages\\numba\\dispatcher.pyc in save_overload(self, sig, cres)\r\n    664                     break\r\n    665             overloads[key] = data_name\r\n--> 666             self._save_index(overloads)\r\n    667 \r\n    668         self._save_data(data_name, cres)\r\n\r\nC:\\Users\\Chris\\Anaconda\\lib\\site-packages\\numba\\dispatcher.pyc in _save_index(self, overloads)\r\n    753     def _save_index(self, overloads):\r\n    754         data = self._source_stamp, overloads\r\n--> 755         data = self._dump(data)\r\n    756         with self._open_for_write(self._index_path) as f:\r\n    757             pickle.dump(self._version, f, protocol=-1)\r\n\r\nC:\\Users\\Chris\\Anaconda\\lib\\site-packages\\numba\\dispatcher.pyc in _dump(self, obj)\r\n    765 \r\n    766     def _dump(self, obj):\r\n--> 767         return pickle.dumps(obj, protocol=-1)\r\n\r\nPicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed\r\n"},"comment":{"url":"https://api.github.com/repos/numba/numba/issues/comments/200944838","html_url":"https://github.com/numba/numba/issues/1681#issuecomment-200944838","issue_url":"https://api.github.com/repos/numba/numba/issues/1681","id":200944838,"user":{"login":"ma-ba","id":10598343,"avatar_url":"https://avatars.githubusercontent.com/u/10598343?v=3","gravatar_id":"","url":"https://api.github.com/users/ma-ba","html_url":"https://github.com/ma-ba","followers_url":"https://api.github.com/users/ma-ba/followers","following_url":"https://api.github.com/users/ma-ba/following{/other_user}","gists_url":"https://api.github.com/users/ma-ba/gists{/gist_id}","starred_url":"https://api.github.com/users/ma-ba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ma-ba/subscriptions","organizations_url":"https://api.github.com/users/ma-ba/orgs","repos_url":"https://api.github.com/users/ma-ba/repos","events_url":"https://api.github.com/users/ma-ba/events{/privacy}","received_events_url":"https://api.github.com/users/ma-ba/received_events","type":"User","site_admin":false},"created_at":"2016-03-24T17:43:11Z","updated_at":"2016-03-24T17:43:11Z","body":"Moreover pickling of `jitclass` instances is not supported, which I guess is currently expected behavior.\r\n```python\r\nfrom multiprocessing import Pool\r\nfrom numba import jitclass, njit, intc\r\n\r\n@jitclass([('value', intc)])\r\nclass Class:\r\n    def __init__(self):\r\n        self.value = 0\r\n\r\n@njit\r\ndef do_nothing(instance):\r\n    return\r\n\r\nwith Pool(1) as pool:\r\n    pool.apply(do_nothing, (Class(),))\r\n```\r\nfails with:\r\n```\r\nTraceback (most recent call last):\r\n  File \"numba_bug_jitclass_pickle.py\", line 14, in <module>\r\n    pool.apply(do_nothing, Class())\r\n  File \"lib/python3.4/multiprocessing/pool.py\", line 253, in apply\r\n    return self.apply_async(func, args, kwds).get()\r\n  File \"lib/python3.4/multiprocessing/pool.py\", line 608, in get\r\n    raise self._value\r\n  File \"lib/python3.4/multiprocessing/pool.py\", line 385, in _handle_tasks\r\n    put(task)\r\n  File \"lib/python3.4/multiprocessing/connection.py\", line 206, in send\r\n    self._send_bytes(ForkingPickler.dumps(obj))\r\n  File \"lib/python3.4/multiprocessing/reduction.py\", line 50, in dumps\r\n    cls(buf, protocol).dump(obj)\r\n_pickle.PicklingError: Can't pickle <class 'numba.jitclass.boxing.Class'>: attribute lookup Class on numba.jitclass.boxing failed\r\n```"}}