[Python-checkins] ABC PEP -- dropping set.clear

Jim Jewett jimjjewett at gmail.com
Thu Apr 26 02:31:39 CEST 2007


On 4/25/07, guido.van.rossum <python-checkins at python.org> wrote:
> +        implementation.)  **Open issues:** Forcing every mutable set
> +        to implement this may be a pain for such a fairly
> +        non-essential method.  Perhaps just drop it?

There are also comments worrying that an abstract implementation would
be horribly slow -- but so what?

Alex Martelli posted some stats (for dicts, I think) showing that
(even today) clear was slower than just creating a new object.   It
still makes sense if you care about the "is" relation

Since you are keeping "pop", the abstract implementation can at least
approximate iteration.

    def clear(self):
        while self.pop(): pass

-jJ


More information about the Python-checkins mailing list