This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients Ruslan Dautkhanov, gvanrossum, levkivskyi
Date 2019-12-31.01:31:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577755875.89.0.318529664307.issue39168@roundup.psfhosted.org>
In-reply-to
Content
Hm, here's what I measure in Python 3.8.1. (I don't use IPython or notebooks so this looks a little different.)


>>> timeit.timeit('Foo()', 'class Foo: pass')
0.37630256199999934


>>> timeit.timeit('Foo()', 'class Foo:\n  def __new__(cls): return super().__new__(cls)')
1.5753196039999864


>>> timeit.timeit('Foo()', 'from typing import Generic, TypeVar\nT = TypeVar("T")\nclass Foo(Generic[T]): pass')
3.8748737150000068


From this I conclude that adding a minimal __new__() method is responsible for about 4x slowdown, and the functionality in typing.py for another factor 2.5.


While this isn't great I don't see an easy way to improve upon this without rewriting the entire typing module in C.  (Some of this may or may not happen for PEP 604.)

PS. I just realized my Python binary was built with debug options, so absolute numbers will look different (better) for you -- but relative numbers will look the same, and I get essentially the same factors with 3.9.0a1+.
History
Date User Action Args
2019-12-31 01:31:15gvanrossumsetrecipients: + gvanrossum, levkivskyi, Ruslan Dautkhanov
2019-12-31 01:31:15gvanrossumsetmessageid: <1577755875.89.0.318529664307.issue39168@roundup.psfhosted.org>
2019-12-31 01:31:15gvanrossumlinkissue39168 messages
2019-12-31 01:31:15gvanrossumcreate