Stefan Behnel added the comment:

Copying the discussion between Antoine and me from python-dev:

>> IMO it should mimic the interface of the TreeBuilder, which
>> calls the data reception method "feed()" and the termination method
>> "close()". There is no reason to add yet another set of methods names
>> just to do what others do already.
>
> Well, the difference here is that after calling eof_received() you can
> still (and should) call events() once to get the last events. I think
> it would be weird if you could still do something useful with the object
> after calling close().
>
> Also, the method names are not invented, they mimick the PEP 3156
> stream protocols:
> http://www.python.org/dev/peps/pep-3156/#stream-protocols

I see your point about close(). I assume your reasoning was to make the 
IncrementalParser an arbitrary stream end-point. However, it doesn't really 
make all that much sense to connect an arbitrary data source to it, as the 
source wouldn't know that, in addition to passing in data, it would also have 
to ask for events from time to time. I mean, you could do it, but then it would 
just fill up the memory with parser events and loose the actual advantages of 
incremental parsing. So, in a way, the whole point of the class is to *not* be 
an arbitrary stream end-point.

Anyway, given that there isn't really the One Obvious Way to do it, maybe you 
should just add a docstring to the class (ahem), reference the stream protocol 
as the base for its API, and then rename it to IncrementalStreamParser. That 
would at least make it clear why it doesn't really fit with the rest of the 
module API (which was designed some decade before PEP 3156) and instead uses 
its own naming scheme.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17741>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to