Crawling Python

Tim Peters tim_one at email.msn.com
Sun Jun 20 04:17:16 CEST 1999


[MK]
> ...
> Win98. I tried the same several more times in DOS box and got
> different results every time:
>
> >>> for i in range(10000):
> ...     s=s+`range(i,i+20)`
> ...
> >>>
> >>>
> >>> len(s)
> 1645360
> >>>

This didn't show len(s) *before* the loop began, so all that can be
concluded is that the loop added no more than 1645360 bytes to s.

> >>> s=''
> >>>
> >>> for i in range(10000):
> ...     s=s+`range(i,i+20)`
> ...
> >>> len(s)
> 1178515
> >>>

This one shows the loop adding exactly 1178515 bytes -- which it does for me
too.

> >>> for i in range(10000):
> ...     s=s+`range(i,i+20)`
> ...
> >>> len(s)
> 2357030
> >>>

s wasn't reset before this loop, so the loop adds an additional 1178515
bytes on top of the 1178515 s started with, and 1178515 + 1178515 = 2357030.

> Now _that_ is weird.

not-really<wink>-ly y'rs  - tim






More information about the Python-list mailing list