[Stackless] Weakref support for tasklets

Bob Ippolito bob at redivi.com
Thu Jan 29 20:32:51 CET 2004


On Jan 29, 2004, at 2:05 PM, Christian Tismer wrote:

> Bob Ippolito wrote:
>
>> I'm committing weakref support for tasklets, because I have a need 
>> for it (giving each tasklet a separate stdin/stdout/stderr by using 
>> proxy objects with __getattr__, since I can not give them separate 
>> sys modules).  I'm not 100% of the ramifications of this, but it was 
>> about a four line change and it doesn't seem to cause any problems 
>> (though it does show how tasklets can be a little odd).
>
> Ok, looking into lines 1220 to 1240 of typeobject.c (py2.2.3 still)
> shows that a weak pointer costs exactly one word, like
> the existence of a __dict__ does.
> Not too bad, although, well it has to have a benefit.
> I have been very tightfisted with tasklet memory, since
> I want to have millions of them.
> But I think your application makes sense.

You should also consider that one word might not make a difference.  
The allocator on Mac OS X, for example, always returns 128bit aligned 
pointers as an optimization for the AltiVec unit.  It completely 
ignores the low 3 bits of any address, so working with unaligned data 
is a chore!

But then again, one word could mean four words -- but that is much less 
often the case :)  I haven't measured it, though.

>> Additionally, would it be useful to put a weakref slot on channels?  
>> I don't need that at the moment, but it might be useful to someone?
>
> No problem with channels, since I expect them to exist
> 10 times fewer than tasklets.

I'll go ahead and add weakref support to them as well.

-bob


_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list