numba
numba copied to clipboard
jitclass doesn't use correct type for init arg
Reporting a bug
- [x] I have tried using the latest released version of Numba (most recent is visible in the release notes (https://numba.readthedocs.io/en/stable/release-notes-overview.html).
- [x] I have included a self contained code sample to reproduce the problem. i.e. it's possible to run as 'python bug.py'.
The issue is easily demonstrated with this example code:
from numba.experimental import jitclass
from numba import uint64
import numpy as np
spec = [
('value', uint64),
]
@jitclass(spec)
class Data(object):
def __init__(self, value: int):
self.value = value
If I instantiate the data objects in this order the code works fine:
data = Data(np.iinfo(np.uint64).max)
data = Data(np.iinfo(np.uint32).max)
But, if I do this:
mybag = Data(np.iinfo(np.uint32).max)
mybag = Data(np.iinfo(np.uint64).max)
I get this error:
Traceback (most recent call last):
File "D:\code\cellcount\cellcount\play3.py", line 15, in <module>
mybag = Data(np.iinfo(np.uint64).max)
File "D:\code\cellcount\lib\site-packages\numba\experimental\jitclass\base.py", line 124, in __call__
return cls._ctor(*bind.args[1:], **bind.kwargs)
OverflowError: int too big to convert
Thanks for the report - I can confirm that I can reproduce the issue locally.