[issue28638] Creating namedtuple is too slow to be used in common stdlib (e.g. functools)

Serhiy Storchaka report at bugs.python.org
Sat Dec 3 05:37:53 EST 2016


Serhiy Storchaka added the comment:

Argument Clinic is used just for running the generating code and inlining the result. This is the simplest part of Argument Clinic and using it looks an overhead. Argument Clinic has other disadvantages:

* In any case you need a rule in Makefile, otherwise the generated code can became outdated.

* Generated code depends not just on the generator code, but on the code of the collections module.

* Even tiny change in the generating code, namedtuple implementation or Argument Clinic code could need regenerating generated code with different checksums.

My second idea, more general solution, was making namedtuple itself using external caching. This would add a benefit for all users of namedtuple without changing a user code or with minimal changes.

namedtuple itself can save a bytecode and a source in files (like Java creates additional .class files for internal classes) and use a bytecode if it is not outdated. Generalized import machinery could be used for supporting generated code in a sync.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28638>
_______________________________________


More information about the Python-bugs-list mailing list