Python and Boehm-Demers GC, I have code.

Christian Tismer tismer at appliedbiometrics.com
Tue Jul 20 08:30:19 EDT 1999


Michael Hudson wrote:
> 
> On 20 Jul 1999, Markus Kohler wrote:
> [snippety snip]
> >
> > Is there anything that would prevent someone to reimplement loops such
> > that only one variable is allocated ?
> >
> 
> Yes. The fact that ints are immutable. Consider:
> 
> for i in xrange(10):
>     if i == 2:
>         j = i
> 
> if the loop only allocated one variable, then at the end of the loop
> 'print j' would give the answer '9'!
> 
> I guess this could be worked around by inspecting refcounts and such...
> but not easily.

FYI, stackless Python already saves the internal loop count into
a counter object. The explicit creation of "i" is still there,
of course. But you might know that inteegr allocation is completely
handled through a cache, and I see not much benefit coming from
making my mutable integer object public.
This look to cheap for me, to be replaced by the hair of extra
refcount tracking.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home




More information about the Python-list mailing list