start | find | index | login or register | edit
2008-12-05
by earl, 3937 days ago
Guido van Rossum - An Optimization Anecdote (from somewhen in 2005, presumably): "The other day, a friend asked me a seemingly simple question: what's the best way to convert a list of integers into a string, presuming that the integers are ASCII values. For instance, the list [97, 98, 99] should be converted to the string 'abc'."

A nice case for "no stinking loops". Not to spoil it, but the two fastest version don't explicitly loop but use built-ins to express the desired effects on a collection. In general, this is the case to be made against the oh-so-flexible for/foreach loops in many languages: it's hard (for the runtime) to gather the intended specific semantics from them, like whether you actually care if the operations are applied in sequence, if you're interested in the results or only in for side-effects, etc.
powered by vanilla
echo earlZstrainYat|tr ZY @.
earl.strain.at • esa3 • online for 6770 days • c'est un vanilla site