On Wed, 4 Oct 2017 08:47:46 +0300
Serhiy Storchaka <storch...@gmail.com>
wrote:
> 04.10.17 07:58, Nick Coghlan пише:
> > For deque specifically, I like Steven D'Aprano's suggestion of a
> > "__dropped__" or "__discard__" subclassing API that makes it
> > straightforward to change the way that queue overruns are handled
> > (especially if raising an exception from the new subclass method can
> > prevent the collection modification entirely - that way you could
> > readily change the deque semantics in a subclass such that if the
> > queue fills up, submitters start getting errors instead of silently
> > discarding older messages, allowing backpressure to be more easily
> > propagated through a system of queues).  
> 
> Wouldn't this harm performance? Looking up the attribute of the type is 
> more costly than pushing/popping the item in the deque.

You would only do that for subtypes, so when Py_TYPE(self) is different
from the base type.  This is a simple pointer comparison.

Nick's idea sounds nice to me, as long as there's an actual use case :-)

Regards

Antoine.


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to