Populating a dictionary, fast
Ben Finney
bignose+hates-spam at benfinney.id.au
Sun Nov 11 17:23:13 EST 2007
DouhetSukd <DouhetSukd at gmail.com> writes:
> Ah, well, just noticed Ben's suggested this already. Mind you, his
> code, while correct in intent, does look a bit fishy (missing those
> square brackets)
By "missing those square brackets", what would be a list comprehension
(allocating an entire list in memory at once before proceeding)
becomes a generator expression (generating results from the sequence
only as needed).
Enter 'python "generator expression"' into your favourite search
engine to find out more.
--
\ "What I resent is that the range of your vision should be the |
`\ limit of my action." -- Henry James |
_o__) |
Ben Finney
More information about the Python-list
mailing list