06.05.18 05:29, Steven D'Aprano пише:
On Sat, 05 May 2018 20:11:28 +0300, Serhiy Storchaka wrote:
Why so slow?
1. Add an overhead of calling eval(), not just looking up its name. It
is comparable with a time of calling a simple lambda. 2. Add an overhead
of getting the globals dict and creating a locals dict.
[...]
Ah, that makes sense.
So presumably the fastest way to run some code in Python is to put it
into a function and call the function, rather than playing with eval or
exec, right?
Right. And advanced implementations, like PyPy can apply optimizations
in this case.
Maybe putting code into an operator implementation will be even faster
because of getting rid of the part of the overhead of calling a
functions. Didn't check this.
--
https://mail.python.org/mailman/listinfo/python-list