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.

_______________________________________________
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