[Twisted-Python] daemon thread support

Bob Ippolito bob at redivi.com
Wed Dec 3 00:19:33 MST 2003


On Dec 3, 2003, at 1:26 AM, Andrew Bennetts wrote:

> On Tue, Dec 02, 2003 at 10:58:05PM -0500, Bob Ippolito wrote:
>> On Dec 2, 2003, at 10:10 PM, Andrew Bennetts wrote:
>>> On Tue, Dec 02, 2003 at 09:46:20PM -0500, Bob Ippolito wrote:
>>>>
>>>> What about list as the function, and itertools.imap as the argument 
>>>> to
>>>> that function?
>>>
>>> Or maybe sets.Set?  So long as process always returns the same value
>>> (probably None), this won't eat memory the way list would...
>>
>> sets.Set eats more memory than list does (it's a python class that 
>> uses
>> a dict for storage).. if you don't want to return anything useful
>> there's always reduce(lambda a,b:None, iterable)
>
> Uh, not if the iterable returns the same element repeatedly.  Compare 
> the
> memory use of:
>
>     sets.Set(itertools.repeat(None))
>
> vs.
>
>     list(itertools.repeat(None))
>
> Your idea with reduce is better -- except that it uses a lambda.  
> Somehow
> that feels like cheating ;)

Fine, no lambda, cheaper than Set (memory and cpu):
	reactor.callInThread(reduce, {}.get, itertools.imap(process, 
iter(queue.get, None)))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20031203/ee20bc13/attachment-0002.bin>


More information about the Twisted-Python mailing list