[Python-ideas] checking for identity before comparing built-in objects

Max Moroz maxmoroz at gmail.com
Thu Oct 4 19:49:45 CEST 2012


On Thu, Oct 4, 2012 at 6:53 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> I'm not sure what you are doing here, because dicts (at least in Python
> 3.2) already short-circuit equality:
>
> py> NAN = float('nan')
> py> NAN == NAN
> False
> py> d = {NAN: 42}
> py> d[NAN]
> 42
>
> Actually, that behaviour goes back to at least 2.4, so I'm not sure how
> you are doing memoization and not seeing the same optimization.

It was my mistake... I do see this optimization now that I know where
to look for it. Thanks for clarifying this.



More information about the Python-ideas mailing list