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:
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 be
On Wed, Oct 21, 2009 at 12:31 PM, Anand Chitipothu 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 object with the
> s
> 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:19 PM, Anand Chitipothu wrote:
> Literal strings are interned. Python maintains a dict of all literal
> strings used in the code and all occurrences get the same object.
>
What do you mean when you use the word "interned"?
id("hello")
> 600320
id("hello")
> 60
On Wed, Oct 21, 2009 at 12:05 PM, Sidharth Kuruvila
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 expecting it t
On Wed, Oct 21, 2009 at 12:05 PM, Sidharth Kuruvila
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 it to evaluate
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 expecting it to evaluate only if the key is
missing.
Regards,
Sidharth
On Wed, Oct 21,
On Wed, Oct 21, 2009 at 8:06 AM, srid 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 pretty murky)
Any idea wh
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/
10 matches
Mail list logo