dict.get and str.xsplit
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Tue Feb 26 09:14:54 EST 2008
On Tue, 26 Feb 2008 06:02:12 -0800, bearophileHUGS wrote:
> This is a real difference, that has real impact on the programs I
> write, so I often use the if/else approach, despite the dict.get()
> method being semantically fitter and shorter.
> So can the dict.get() method be speed up? And if not, why?
I guess it's the method lookup that's the slow part. Factor it out of the
loop and measure again::
adict_get = adict.get
for _ in xrange(M):
for k in keys1:
r = adict_get(k, None)
for k in keys2:
r = adict_get(k, None)
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list