On 4/11/07, Walter Dörwald <[EMAIL PROTECTED]> wrote:
> Would it make sense to make the state of the decoder public, e.g. by
> adding setstate() and getstate() methods? This would give a cleaner API.

I've been thinking of the same thing!

I wonder if it would be possible to return the state as a pair
(unread, flags) where unread is a (byte) string of unprocessed bytes
and flags is some other state, with the constraint that in the initial
state the flags must be zero. Then I can optimize the case where flags
is returned as zero by subtracting len(unread) from the current
position and that'd be the correct seek position. I imagine most
decoders have only very few flags they care about. (The worst might be
the utf-16 decoder which must have a flag to remember whether it
already saw a byte order marker, and another indicating the byte
order. Maybe we'll have to special-case that one, so don't worry too
much about it.)

> Should I work on a patch?

That would be great!

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to