On Wed, Oct 21, 2009 at 12:05 PM, Sidharth Kuruvila
sidharth.kuruv...@gmail.com wrote:
d = {a:Hello}
print d.setdefault(a, blah)
Even though the string blah is not being used an object has to be
created to represent it. Even worse, you could put some complex
expression in there expecting
On Wed, Oct 21, 2009 at 12:05 PM, Sidharth Kuruvila
sidharth.kuruv...@gmail.com wrote:
Hi,
d = {a:Hello}
print d.setdefault(a, blah)
Even though the string blah is not being used an object has to be
created to represent it. Even worse, you could put some complex
expression in there
What do you mean when you use the word interned?
$ pydoc intern
Help on built-in function intern in module __builtin__:
intern(...)
intern(string) - string
``Intern'' the given string. This enters the string in the (global)
table of interned strings whose purpose is to speed up
On Wed, Oct 21, 2009 at 12:31 PM, Anand Chitipothu anandol...@gmail.com wrote:
``Intern'' the given string. This enters the string in the (global)
table of interned strings whose purpose is to speed up dictionary lookups.
Return the string itself or the previously interned string
Hi,
My bad, that was a bit of laziness on my part. The reason why my
code was silly is not to do with interning though that does happen for
strings. Literals, that is numbers and string literals and a few
others are loaded as constants. So the cost of constructing them in
your code has already
On a similar note, here's a question I recently asked and obtained good
input about tail recursion optimization.
http://stackoverflow.com/questions/1414581/python-recursive-program-to-prime-factorize-a-number
On Wed, Oct 21, 2009 at 1:14 PM, Sidharth Kuruvila
sidharth.kuruv...@gmail.com wrote:
http://stackoverflow.com/questions/1597764/is-there-a-better-pythonic-way-to-do-this
Someone wrote their *first* Python program asking for a more Pythonic
way to do it ... and gets valuable feedback from the community
including Alex Martelli.
I am now researching on a way to gather top posts (w/
On Wed, Oct 21, 2009 at 8:06 AM, srid sridhar.ra...@gmail.com wrote:
http://stackoverflow.com/questions/1597764/is-there-a-better-pythonic-way-to-do-this
Nice. Martelli says:
(avoid setdefault, that was never a good design and doesn't have
good performance either, as well as being