Socket Performance

Bryan Olson fakeaddress at nowhere.org
Sat Mar 15 09:18:01 EDT 2008


castironpi at gmail.com wrote:
> Gabriel Genellina wrote:
>> No need to reinvent the wheel. socket objects already have a makefile  
>> method returning a file-like object, which behaves like a buffered socket.

That wheel is far from round, and needs some reinvention. Python's
file-like objects do not play nice with lower level calls, which
would be tolerable if they supported some well-defiend high-level
asynchronous I/O, but they do not.

> Newbie question:  Can you write to the 'file-like object' a pickle,
> and receive it intact-- as one string with nothing else?

Yes, but there's a world of gotcha's. Sockets do not recognize
record boundaries, and Python's 'pickle' has holes one's enemies
could drive a truck through. Still, you can pickle, write, read,
un-pickle, and get back your data intact.

> I want to know because I want to send two pickles.

"Two pickles" sounds like a tasty snack, but also suggests you may
be playing hopscotch in a minefield. This is a helpful group. Give
us more to go on, and you are likely to receive thousands of
dollars worth of consulting for free.


-- 
--Bryan



More information about the Python-list mailing list