Am Fr., 9. Sept. 2022 um 23:59 Uhr schrieb John Cowan <[email protected]>:

>
>> As a side remark: Using `iota` like this shouldn't be used with great care 
>> as it constructs a list in memory which is then discarded.
>
>
> Unless it is larger than the size of the GC nursery, it doesn't really cost 
> anything.

Does it really not cost anything?

It does produce garbage in the GC nursery (unless the compiler is
"sufficiently smart"), so a minor GC will kick in earlier. This will
at least touch the then-live objects in the nursery. Depending on how
much the minor GC will be triggered, this should make a difference.
Python 2 offered `xrange' as a replacement for `range', for example.

Reply via email to