On 2019-06-07 20:42, Terry Reedy wrote:
On 6/7/2019 6:41 AM, Jeroen Demeyer wrote:
Hello,

I'm starting this thread to brainstorm for using vectorcall to speed
up creating instances of Python classes.

Currently the following happens when creating an instance of a Python
class X using X(.....) and assuming that __new__ and __init__ are
Python functions and that the metaclass of X is simply "type":

1. type_call (the tp_call wrapper for type) is invoked with arguments
(X, args, kwargs).

2. type_call calls slot_tp_new with arguments (X, args, kwargs).

3. slot_tp_new calls X.__new__, prepending X to the args tuple. A new
object obj is returned.

4. type_call calls slot_tp_init with arguments (obj, args, kwargs).

5. slot_tp_init calls type(obj).__init__ method, prepending obj to the
args tuple. A new object obj is returned.

My understanding is that the argument obj is just mutated, which is one
reason why a separate __new__ is needed.

Yes indeed. I just accidentally copy-pasted that sentence :-)
_______________________________________________
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/RYHMJNNK7JX3BMZQU7YC4SLOA7DA3DNA/

Reply via email to