One worry that I have in general with this move is the usage of _PyType_GetModuleByDef to get the type object from the module definition. This normally involves getting a TLS in every instance creation, which can impact notably performance for some perf-sensitive types or types that are created a lot.
On Tue, 12 Jan 2021 at 18:21, Neil Schemenauer <nas-pyt...@arctrix.com> wrote: > On 2021-01-12, Victor Stinner wrote: > > It seems like a safer approach is to continue the work on > > bpo-40077: "Convert static types to PyType_FromSpec()". > > I agree that trying to convert static types is a good idea. Another > possible bonus might be that we can gain some performance by > integrating garbage collection with the Python object memory > allocator. Static types frustrate that effort. > > Could we have something easier to use than PyType_FromSpec(), for > the purposes of coverting existing code? I was thinking of > something like: > > static PyTypeObject Foo_TypeStatic = { > } > static PyTypeObject *Foo_Type; > > PyInit_foo(void) > { > Foo_Type = PyType_FromStatic(&Foo_TypeStatic); > } > > > The PyType_FromStatic() would return a new heap type, created by > copying the static type. The static type could be marked as being > unusable (e.g. with a type flag). > _______________________________________________ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@python.org > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/python-dev@python.org/message/RPG2TRQLONM2OCXKPVCIDKVLQOJR7EUU/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/HOCGUW3S6AXBSQ5BWX5KYPFVXEGWQJ6H/ Code of Conduct: http://python.org/psf/codeofconduct/