Duncan Booth duncan.bo...@invalid.invalid writes:
The suggested alternative:
value = data.get(key, None)
also has two dictionary lookups:...
dg = data.get
...
(inside loop):
value = dg(key,None)
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
On Sat, 27 Jun 2009 09:41:13 -0700, Rachel P wrote:
[...]
Raymond
Raymond, does Rachel know you're using her gmail account?
It's a good thing names are being used here, rather than just initials.
--
\“No one ever
On Jun 27, 4:40 am, Duncan Booth duncan.bo...@invalid.invalid wrote:
Thomas Lehmann iris-und-thomas-lehm...@t-online.de wrote:
Hi!
In C++, programming STL you will use the insert method which always
provides a position and a flag which indicates whether the position
results from a new
On Sun, 28 Jun 2009 02:57:50 -0700, Carl Banks wrote:
So it's not valid in general to equate the two lookups. Unless you know
that your dict keys are going to be really fast like interned strings it
makes sense to minimize dict lookups.
Or to stop making assumptions about what's fast and
Hi!
In C++, programming STL you will use the insert method which always
provides a position and a flag which indicates whether the position
results from a new insertion or an exisiting element. Idea is to have
one search only.
code
if data.has_key(key):
value = data[key]
/code
But this does
On Sat, Jun 27, 2009 at 2:47 AM, Thomas
Lehmanniris-und-thomas-lehm...@t-online.de wrote:
Hi!
In C++, programming STL you will use the insert method which always
provides a position and a flag which indicates whether the position
results from a new insertion or an exisiting element. Idea is
Thomas Lehmann iris-und-thomas-lehm...@t-online.de writes:
code
if data.has_key(key):
value = data[key]
/code
But this does mean (does it?) that the dictionary is searched two
times! If so, can somebody show me how to do this in one step?
value = data.get(key, None)
sets value to
Thomas Lehmann iris-und-thomas-lehm...@t-online.de wrote:
Hi!
In C++, programming STL you will use the insert method which always
provides a position and a flag which indicates whether the position
results from a new insertion or an exisiting element. Idea is to have
one search only.
[Thomas Lehmann]
In C++, programming STL you will use the insert method which always
provides a position and a flag which indicates whether the position
results from a new insertion or an exisiting element. Idea is to have
one search only.
code
if data.has_key(key):
value = data[key]
Thomas Lehmann wrote:
In C++, programming STL you will use the insert method which always
provides a position and a flag which indicates whether the position
results from a new insertion or an exisiting element. Idea is to have
one search only.
code
if data.has_key(key):
value = data[key]
On Sat, 27 Jun 2009 09:41:13 -0700, Rachel P wrote:
[...]
Raymond
Raymond, does Rachel know you're using her gmail account?
*wink*
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
11 matches
Mail list logo