Speed *triples* by changing 'apply(f, args)' to 'f(*args)'

Roman Suzi rnd at onego.ru
Wed Mar 5 16:22:28 EST 2003


On 5 Mar 2003, Aahz wrote:

>In article <mailman.1046829310.19920.python-list at python.org>,
>Tim Peters  <tim.one at comcast.net> wrote:
>>
>>There's more than meets the eye: because the apply() builtin is
>>deprecated now, the implementation of __builtin__.apply() now calls
>>warnings.warn() (a Python function) to see whether it should issue
>>a deprecation warning.  So the former also costs a new hidden call
>>to a long Python function now, which in turn does many lookups and
>>additional calls (both C and Python level) of its own.  Luckily,
>>Gerritt already figured out the best fix <wink>.
>
>Ouch.  Should we consider postponing the official deprecation of apply()
>for one more release?  I'm concerned about the possible speed of the
>logging module.

Wow! apply() is going to be deprecated! Faster lane is under construction!
("there is only one obvious way")

>>> def today1(*fff): print fff
...
>>> today1(*[2])
(2,)
>>> def today2(**fff): print fff
...
>>> k = {'a':1,'b':2,'c':3}
>>> today2(**k)
{'a': 1, 'c': 3, 'b': 2}
>>> def tomorrow(fff): print fff()
...
>>> tomorrow(:len('123'))
3

i-need-to-read-c.l.p-more-frequently-yours,
Roman Suzi
-- 
rnd at onego.ru =\= My AI powered by Linux RedHat 7.3






More information about the Python-list mailing list