Re: [Python-Dev] cStringIO buffer interface On Wed, 30 Apr 2008 09:51:25 -0700, Guido van Rossum  wrote:
>On Wed, Apr 30, 2008 at 9:36 AM, Farshid Lashkari  wrote:
>>  I was just curious as to why cStringIO objects don't implement the
>>  buffer interface.  cStringIO objects seem similar to string and array
>>  objects, and those support the buffer protocol. Is there a reason
>>  against allowing cStringIO to support at least the read buffer
>>  interface, or is just that nobody has considered it until now?
>
>Well, for one, it would mean you could no longer exchange a StringIO
>instance for a cStringIO instance.

It would probably only mean that there is one further incompatibility
between cStringIO and StringIO - you already can't exchange them in a
number of cases.  They handle unicode differently, they have different
methods, etc.

Maybe making them diverge even further is a step in the wrong direction,
though.

>Also, what's the compelling use case you're thinking of?

I'm not sure what use-case Farshid Lashkari had.  For Twisted, it has
been considered as a way to reduce peak memory usage (by reducing the
need for memory copying, which also speeds things up).  I'm not sure
if anyone has benchmarked this yet, so I don't know if it's a real win
or not.  I think Thomas HervÃ© has a patch to cStringIO which implements
the feature, though.

For reference, .

This isn't high on my priority list, but I thought I'd point out the
potential use-case.

Jean-Paul
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev%40tangomu.com

