[Python-ideas] Putting `blist` into collections module

Guido van Rossum guido at python.org
Mon Sep 22 21:28:37 CEST 2014


On Mon, Sep 22, 2014 at 12:19 PM, David Wilson <dw+python-ideas at hmmz.org>
wrote:

> Another concern is structures that rely on comparison could become
> performance hazards as they are mixed with user subclasses that perform
> nontrivial work in their __lt__ methods, and suchlike. That's a
> potentially undesirable trait for a built-in type.
>

I don't get this objection. If a user-defined subclass has slow comparisons
then the container containing it becomes slow. You can't blame that on the
(fast) base class nor on the container type. The same applies to ==: if I
write a str subclass that overrides __eq__ with a slower version than dict
lookups become slower. The solution is simple: don't do that.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140922/62297842/attachment.html>


More information about the Python-ideas mailing list