Added
- `impl` now has an optional keyword argument `alloc`, with options of `"all", "sequence", "mapping"`. The default of `None` will automatically allocate `PyMethods` when a slot name being set is not allocated on the type.
- The setting `"all"` will unconditionally allocate all `PyMethods` (PyAsyncMethods, PyNumberMethods, PySequenceMethods, PyMappingMethods) before the impl.
- "sequence" and "mapping" options will allocate the respective PyMethods when the slot name is ambiguious (such as `__len__` and `__getitem__`, which are in both `PySequenceMethods` and `PyMappingMethods`.
- `orig` now works within `__new__` impls. `orig(cls)` will return a custom slot wrapper to `tp_new` that will resolve further subclasses without a custom `__new__` as `object.__new__` instead. This also handles the special case where `object.__new__` has a different signature than `CustomType.__new__`
python
from einspect import impl, orig
impl(object)
def __new__(cls, *args, **kwargs):
print("in new:", cls, args, kwargs)
return orig(cls).__new__(cls, *args, **kwargs)
class Foo:
...
print(object())
in new: <class 'object'> () {}
<object object at 0x000001EA9D2A4FE0>
print(Foo())
in new: <class '__main__.Foo'> () {}
<__main__.Foo object at 0x000001EA9D797DD0>
**Full Changelog**: https://github.com/ionite34/einspect/compare/v0.5.8...v0.5.9