New submission from Antoine Pitrou <pit...@free.fr>:

As mentioned in 
https://mail.python.org/pipermail/python-dev/2017-December/151298.html, slot 
lookup can take 75 to 80% of the runtime when creating a new class.  This was 
slightly improved in https://bugs.python.org/issue31336 but we're still doing 
one lookup per possible slot name *and* per class along the MRO.

I propose to speed up this step by caching the known descriptors for each 
class.  This way, when instantiating a new class, you can simply iterate over 
the known descriptors of the MRO without wasting time on hundreds of dict 
lookups.

(and it is reasonably easy to find all slot descriptors in a dict: first select 
only __dunder__ names, then look them up in a dedicated mapping)

----------
components: Interpreter Core
messages: 308474
nosy: pitrou, scoder, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Speed up slot lookup for class creation
type: performance
versions: Python 3.7

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

Reply via email to