Nested dict-of-jitclass throws pickling error
See original GitHub issueNumba 0.52.0, 64-bit Python 3.7.3 on Windows Discourse discussion is here
The code below doesn’t work, but seems like it ought to
from numba import types, typed, njit
from numba.experimental import jitclass
@jitclass([
("x", types.int64),
])
class Level1:
def __init__(self):
self.x = 12
level1 = Level1() # Okay, I can create a Level1 instance
level1_instance_type = Level1.class_type.instance_type
level1_kv = (types.int64, level1_instance_type)
@jitclass([
("level1s", types.DictType(*level1_kv)),
])
class Level2(object):
def __init__(self):
self.level1s = typed.Dict.empty(*level1_kv)
self.level1s[0] = Level1()
level2 = Level2() # Okay, I can create a Level2 instance
level2_instance_type = Level2.class_type.instance_type
level2_kv = (types.int64, level2_instance_type)
@jitclass([
("level2s", types.DictType(*level2_kv)),
])
class Level3(object):
def __init__(self):
self.level2s = typed.Dict.empty(*level2_kv)
# _pickle.PicklingError: Can't pickle <class 'numba.experimental.jitclass.base.Level1'>: it's not found as numba.experimental.jitclass.base.Level1
# level3 = Level3()
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Python multiprocessing PicklingError: Can't pickle <type ...
Update: The function I pickle is defined at the top level of the module. Though it calls a function that contains a nested...
Read more >Mailman 3 Pickling instances of nested classes - Python-Dev
Currently instances of nested classes can't be pickled. For old style classes unpickling fails to find the ... PicklingError: Can't pickle <class '__main__....
Read more >Python Pickle: Serialize Your Objects [With Examples]
Pickle a Nested Dictionary Object. Let's find out if a Python nested dictionary can be serialized and deserialized using the Pickle module.
Read more >PicklingError in pyspark (PicklingError: Can't pickle <class ...
Possible answer from here. The problem is that you're trying to pickle an object from the module where it's defined. If you move...
Read more >Fixing pickle for nested classes — Sage 9.3.beta9 Reference ...
So there is no pickling problem for nested classes in Python 3, and the two utilities are not really necessary. However, NestedClassMetaclass is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tombh thanks I can confirm I am seeing this on
master
(5f6859908e7b73f7e1baf30381bac9e863640210) too.This still reproduces, on OSX even with current
master
(cbb4301852d0950f15eef0a2b8c0478db5d57201):