Python and the need for speed

Gregory Ewing greg.ewing at
Sun Apr 9 20:21:07 EDT 2017

Chris Angelico wrote:

>>From that page:
>>Other candidates for banishment from TurboPython include eval and exec.

I'm not convinced that removing eval and exec has anything to
do with making Python faster. There has to be a compiler
somewhere in the system, and making it invokable at run time
doesn't necessarily mean code that doesn't use that feature
has to run slower.

Heck, you can write an exec() function for C if you really
want. Run the C compiler in another process, dynamically
load the object file and call it. Doing that would be very
inefficient, but it wouldn't slow down the rest of your
C code.

My take on the idea of making Python less dynamic in order
to improve speed is that you'll end up with a language that,
while it may superficially resemble Python, doesn't
really feel like Python.

Boo is an example of that. It has a Python-like syntax, but
to get any speed advantage you need to add static type
delarations, and then it feels more like programming in
C# than Python. At that point, you wonder whether you might
just be better off writing your program in C# to begin with.

That's not to say this kind of approach isn't worth pursuing,
but like the JIT attempts mentioned in the article, it has
also been tried before, with varying levels of success.


More information about the Python-list mailing list