Nick Coghlan added the comment:

I'll echo Raymond's concerns here, as we simply don't have the collective 
maintenance capacity to sustain a plethora of special case micro-optimisations 
aimed at avoiding importing common standard library modules.

I will note however, that there has been relatively little work done on 
optimising CPython's code generator, as the use of pyc files and the fact 
namedtuples are typically only defined at start-up already keeps it out of the 
critical path in most applications.

While work invested there would technically still be a micro-optimisation at 
the language level, it would benefit more cases than just avoiding the use of 
namedtuple in functools would.

Alternatively, rather than manually duplicating the namedtuple code and having 
to keep it in sync by hand, you could investigate the work Larry Hastings has 
already done for Argument Clinic in Python's C files: 
https://docs.python.org/3/howto/clinic.html

Argument Clinic already includes the machinery necessary to assist with 
automated maintenance of generated code (at least in C), and hence could 
potentially be adapted to the task of "named tuple inlining". If Victor's AST 
transformation pipeline and function guard proposals in PEP's 511 and 510 are 
accepted at some point in the future, then such inlining could potentially even 
be performed implicitly some day.

Caring about start-up performance is certainly a good thing, but when 
considering potential ways to improve the situation, structural enhancements to 
the underlying systems are preferable to ad hoc special cases that complicate 
future development efforts.

----------

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

Reply via email to