- init = cls.class_type.instance_type.methods['__init__']
- init_sig = utils.pysignature(init)
- # get postitional and keyword arguments
- # offset by one to exclude the `self` arg
- args = _getargs(init_sig)[1:]
- cls._ctor_sig = init_sig
- ctor_source = _ctor_template.format(args=', '.join(args))
- glbls = {"__numba_cls_": cls}
- exec(ctor_source, glbls)
- ctor = glbls['ctor']
- cls._ctor = njit(ctor)
- def __instancecheck__(cls, instance):
- if isinstance(instance, _box.Box):
- return instance._numba_type_.class_type is cls.class_type
- return False
- def __call__(cls, *args, **kwargs):
- # The first argument of _ctor_sig is `cls`, which here
- # is bound to None and then skipped when invoking the constructor.
- bind = cls._ctor_sig.bind(None, *args, **kwargs)