You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
... for non-singleton default arguments (ie booleans and small ints seem ok, floats fail).
fromnumbaimportjitDEFAULT=123456789@jit(nopython=True, cache=True)defx_or_default(x=DEFAULT):
returnxx_or_default()
# looks like the compile result gets written into a .nbc fileoverloads=x_or_default._cache._cache_file._load_index()
print('Cached overloads: ', overloads)
# but you cannot load the compile result from cacheassertx_or_default._cache.load_overload(
(types.Omitted(DEFAULT),), x_or_default.targetctx
) isnotNone# the cause seems to be that the unpickled Omitted(DEFAULT) does not equal# the newly created one, ie he following failsassertlist(overloads)[0][0][0] ==types.Omitted(DEFAULT)
assertlist(overloads)[0][0][0] ==list(
x_or_default._cache._cache_file._load_index())[0][0][0]
The code above will work for DEFAULT=123 (likely due to Python's small int caching)
The text was updated successfully, but these errors were encountered:
To get the above working you had to return type(self.value), self.value. But that will break for any unhashable default value. Maybe need to keep the current behaviour for unhashable default values.
Thanks for the report. I can reproduce, even the round trip fails:
fromnumbaimportjitfromnumbaimporttypesDEFAULT=123456789@jit(nopython=True, cache=True)defx_or_default(x=DEFAULT):
returnxx_or_default()
# looks like the compile result gets written into a .nbc fileoverloads=x_or_default._cache._cache_file._load_index()
print('Cached overloads: ', overloads)
# Round trip failskey= [_for_inoverloads][0]
assertx_or_default._cache.load_overload(key, x_or_default.targetctx)
... for non-singleton default arguments (ie booleans and small ints seem ok, floats fail).
The code above will work for
DEFAULT=123
(likely due to Python's small int caching)The text was updated successfully, but these errors were encountered: