[Python-Dev] PEP 0424: A method for exposing a length hint
Steven D'Aprano
steve at pearwood.info
Sun Jul 15 18:39:01 CEST 2012
Steven D'Aprano wrote:
> With a length hint, we could strengthen that promise:
>
> "if __length_hint__ returns a negative number, list, tuple and set will
> fail immediately with MemoryError"
>
> which I think is a good safety feature for some things which cannot
> possibly succeed, but risk DOSing your system. Does it prevent every
> possible failure mode? No, of course not. But just because you can't
> prevent *every* problem doesn't mean you should prevent the ones which
> you can.
Gah, I messed that last sentence up. It should read:
just because you can't prevent *every* problem doesn't mean you SHOULDN'T
prevent the ones which you can.
--
Steven
More information about the Python-Dev
mailing list