Winter Madness - Passing Python objects as Strings
gagsl-py2 at yahoo.com.ar
Fri Jun 5 12:54:30 CEST 2009
En Fri, 05 Jun 2009 07:00:24 -0300, Hendrik van Rooyen
<mail at microcorp.co.za> escribió:
> "Terry Reedy" <tj. at udel.edu> wrote:
>> You have multiple threads within a long running process. One thread
>> repeatedly reads a socket.
> Yes and it puts what it finds on a queue. - it is a pre defined simple
> delimited record.
>> You wanted to be able to occasionally send
>> an object to that thread.
> Close - to another thread that reads the queue, actually.
>> Rather than rewrite the thread to also poll a
>> queue.Queue(), which for CPython sends objects by sending a pointer,
> It is in fact reading a queue, and what it gets out in the vast majority
> cases is the record that came from the socket.
Ah... I had the same impression as Mr. Reedy, that you were directly
reading from a socket and processing right there, so you *had* to use
strings for everything.
But if you already have a queue, you may put other objects there (instead
of "canning" them). Testing the object type with isinstance(msg, str) is
pretty fast, and if you bind locally those names I'd say the overhead is
More information about the Python-list