[Python-Dev] Impact of Namedtuple on startup time

Christian Heimes christian at python.org
Mon Jul 17 11:19:46 EDT 2017


On 2017-07-17 14:43, Antoine Pitrou wrote:
> So my take is:
> 
> 1) Usage of "_source" in open source code (as per the search above)
> seems non-existent.
> 
> 2) If the primary intent of "_source" is to show-case how to write a
> tuple subclass, well, why not write a recipe or tutorial somewhere?
> The Python stdlib is generally not a place where we reify tutorials or
> educational snippets as public APIs.
> 
> 3) The well-known namedtuple would really benefit from a performance
> boost, without asking all maintainers of dependent code (that's a
> *ton*) to migrate to a new idiom + compatibility fallback.

I have an additional take on named tuples

4) The current approach uses exec() to generate the namedtuple class on
the fly. The exec() function isn't necessarily evil and the use of
exec() in namedtuple is safe. However I would appreciate if Python
interpreter could be started without requiring the exec() function. It
would make it easier to harden the interpreter for embedding and system
integration uses cases.

It's not about sandboxing Python. My goal is to make it harder to abuse
Python. See Steve's lighting talk "Python as a security vulnerability"
at the language summit, https://lwn.net/Articles/723823/ .

Christian




More information about the Python-Dev mailing list