Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
c00w
· 14y ago · 0 comments
return ''.join(`num` for num in xrange(loop_count))
is better than
return ''.join([`num` for num in xrange(loop_count)])
Comments
[–]
rabidsnail
14y ago
The latter will allocate all of the integers and then free them as they're joined. The former will allocate one integer, then add it to the string and free it, then allocate another integer.