Replacement for locals() ???
Christian Tismer
tismer at stackless.com
Sat Jul 31 07:35:28 EDT 2004
Harald Massa wrote:
> Terry,
>
>
>
>>>So two of the greatest PythonBrains have problems in optimizing
>>>Python because of locals(), the most common usage of Python in my
>>>practice is peripheral; so just by way of precaution I am looking for
>>>a
>>>r eplacement.
>>
>>I suspect you are very prematurely optimizing. Since you are filling
>>out SQL statements, I would expect that your bottlenecks are and will
>>be the execution of the statements, and not the construction of the
>>statements.
>
>
> you are partially right. I do not have ANY performance problems in that
> Python code. Most of the time the program is either waiting for a
> COM-Server, a database-Server or user-typing.
>
> As Skip stated: using locals() prevents the EASY use of psyco.
> (import psyco; psyco full
Ok, I see. Note that the EASY use is almost always much slower
than a partial, controlled usage of Psyco, for non-trivial
applications.
The bad thing about locals() is that it simply goes wrong
with Psyco. I think it would be nicer if psyco would
simply refuse optimization in this case and leave things intact.
There are some constructs which just disable Psyco: If the
code contains certain opcodes, Psyco will not touch the whole
function. Examples are:
- generators: an existing yield disables Psyco for the func
- usage of nested scopes.
On the scopes case: If you have a construct like this:
def outer():
something = 42
def inner():
print something
inner()
Then both outer and inner will contain opcodes which disable
Psyco from touching things at all.
So if you can manage to inject such a construct, your locals
will be fine with Psyco.full().
Anyway, I think we should hint Armin (the other one) to
change the locals behavior to disable Psyco.
ciao - chris
--
Christian Tismer :^) <mailto:tismer at stackless.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
More information about the Python-list
mailing list