[Tutor] Hex to Str - still an open issue

Karl Pflästerer sigurd at 12move.de
Sun Feb 6 15:23:27 CET 2005


On  6 Feb 2005, kent37 at tds.net wrote:

> Actually, generating the digits from the right complicates the algorithm quite
> 	a bit. It's hidden in
> the Python version, but s = str(i % 2) + s is a relatively expensive operation here - it has to copy 
> all of s to make room for the new digit.

Because of that the standard answer is to write:

s = []
s.append(...)
return ''.join(s)



   Karl
-- 
Please do *not* send copies of replies to me.
I read the list


More information about the Tutor mailing list