News for hackers. Stuff that matters.
Re:Python idioms by beaumartinez on Sunday June 12, 2011 @03:01PM (#2647117)
Did you try itertools.imap instead? Vanilla map gives us a list; imap gives us a generator. (Also, I'd try a generator expression as well to see how it compares to a list comprehension).

Also, note that the article is from January 2007; I'd wager that Python has evolved and had a wealth of optimisations since then, especially regarding "common idioms" such as vanilla string concatenation and list comprehensions.

Re:Python idioms by Estragon on Sunday June 12, 2011 @03:59PM (#2647254)

  > ...the article is from January 2007; I'd wager that Python has
  > evolved and had a wealth of optimisations since then...
The observations I made regarding list-comprehensions vs map have been true since list comprehensions were first introduced.

  > Did you try itertools.imap instead? Vanilla map gives us a list;
  > imap gives us a generator.
Don't see why that would make any difference (except to confuse the benchmark, as the python3 examples in this thread show.)