Marcel Zięba <mars...@gmail.com> added the comment:

"It seems creating the signature of NonCallableMock.__init__ per mock creation 
is expensive and since it doesn't change can we just create the signature once 
and set it as a module level attribute? There might still be room for some more 
optimisations here to reduce the impact."

This is already done in master branch ;)


"This could be moved to _get_child_mock so that the Mock creation itself for 
all other mocks and common use case is faster. Creating child mocks will have 
the iscoroutine function check performed where maybe we can populate the 
_spec_async list and use it for subsequent calls."

This seems like a reasonable solution.
I've tested it and it improves mock creation speed 2x.

Do you mind if I create PR for it? I would like to start contributing to 
CPython ;)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38895>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to