Re: loop beats generator expr creating large dict!?

2006-10-04 Thread David Isaac
Alan Isaac wrote: The current situation is: use a loop because the obvious generator approach is not efficient. Fredrik Lundh [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] not efficient compared to what ? I already guess that I've missed your point, but to prove it... I was

Re: loop beats generator expr creating large dict!?

2006-10-03 Thread Ant
George Young wrote: ... I am puzzled that creating large dicts with an explicit iterable of key,value pairs seems to be slow. I thought to save time by doing: palettes = dict((w,set(w)) for w in words) instead of: palettes={} for w in words: palettes[w]=set(w) In the

Re: loop beats generator expr creating large dict!?

2006-10-03 Thread David Isaac
Does George's example raise the question: why do dictionaries not implement efficient creation for two common cases? - Making a dict from two sequences of the same length. - Making a dict from a sequence and a function (as in George's example in this thread). The current situation is: use a

Re: loop beats generator expr creating large dict!?

2006-10-03 Thread Fredrik Lundh
David Isaac wrote: The current situation is: use a loop because the obvious generator approach is not efficient. not efficient compared to what ? /F -- http://mail.python.org/mailman/listinfo/python-list

Re: loop beats generator expr creating large dict!?

2006-10-03 Thread Steven Bethard
David Isaac wrote: Does George's example raise the question: why do dictionaries not implement efficient creation for two common cases? - Making a dict from two sequences of the same length. - Making a dict from a sequence and a function (as in George's example in this thread). Maybe

Re: loop beats generator expr creating large dict!?

2006-10-03 Thread Steve Holden
Fredrik Lundh wrote: David Isaac wrote: The current situation is: use a loop because the obvious generator approach is not efficient. not efficient compared to what ? Compared to understanding what's actually going on and working with reality as opposed to some superstitious view of

loop beats generator expr creating large dict!?

2006-10-02 Thread George Young
[Python 2.5c2 (r25c2:51859, Sep 17 2006, 19:57:40), sparc solaris] I am puzzled that creating large dicts with an explicit iterable of key,value pairs seems to be slow. I thought to save time by doing: palettes = dict((w,set(w)) for w in words) instead of: palettes={} for w in words:

Re: loop beats generator expr creating large dict!?

2006-10-02 Thread Ben Cartwright
George Young wrote: I am puzzled that creating large dicts with an explicit iterable of key,value pairs seems to be slow. I thought to save time by doing: palettes = dict((w,set(w)) for w in words) instead of: palettes={} for w in words: palettes[w]=set(w) where words