Python never sits still. With each iteration, both the Python language and its most widely used implementation, CPython, move forward to make life a little easier for everyone using them.
As Python becomes more popular, and its use cases expand, certain Python limitations—from slow startup to the lack of concurrency—become more glaring. The latest set of improvements are driven by the demands being imposed on Python in realms as diverse as automation, machine learning, and microservices.
Here we look at four key areas in which Python’s core development team is pushing for major improvements.
Shortening Python’s startup time
Many of the improvements planned for Python fall into the general bucket of “make things faster.” One optimization at the top of the list is reducing the amount of time the CPython interpreter needs to start up. This may provide the biggest short-term bang for the development buck.
There is no question Python’s startup time is a problem. Core CPython developer Victor Stinner has demonstrated that Python 3.7 (the current trunk version) starts anywhere from 2.3 to 2.8 times slower than Python 2.7. Perl 5 and PHP 7 launch five to 10 times faster than Python 3.
Python 3’s sluggish starts are hardly incentive to persuade Python 2.x users to upgrade, all the more urgent given Python 2’s end-of-life in 2020. Nor does it help make a case for using Python, specifically, CPython, in environments where a short startup time is part of the job description—for instance, as a language runtime in a container. The shorter the startup time, the faster the container is ready to accept commands, and the more useful the language will be in any containerized environment (AWS Lambda, for instance).
Speeding up Python’s named tuples
One of the most general ways CPython’s core developers are eyeing to speed up the runtime—including startup time—is a faster implementation of named tuples.
Tuples in Python are immutable lists of objects, such as integers or strings, that are accessed by their index positions—element 0, element 1, and so on. Named tuples, available in Python’s standard library, allow access to these elements by way of a dot attribute—e.g.,
address.zip_code instead of
address. This can make code much easier to read.
However, the current implementation of named tuples has been implicated as one of the possible culprits in Python’s slow startup time. Thus Python creator Guido van Rossum has decreed that named tuples should be vigorously optimized in CPython—both for the benefits it will provide CPython’s startup time, and for the benefits that will cascade down to all of the third-party applications that use CPython.
Sign up for Computerworld eNewsletters.