[Python-ideas] Identity dicts and sets (original) (raw)
Christian Heimes christian at python.org
Thu Jan 3 16:10:20 CET 2013
- Previous message: [Python-ideas] Identity dicts and sets
- Next message: [Python-ideas] Identity dicts and sets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Am 03.01.2013 04:37, schrieb Nick Coghlan:
This can be important in some use cases:
1. It's more correct for caching. For example, "0 + 0" should give "0", while "0.0 + 0.0" should give "0.0". An identity based cache will get this right, a value based cache will get it wrong (functools.lrucache actually splits the difference and goes with a type+value based cache rather than a simple value based cache)
Do you mean +0.0 or -0.0? IEEE 754 zeros are always signed although +0.0 is equal to -0.0. And NaNs are always unequal to all NaNs, even to itself. For floats we would need a type specified dict that handles special values correctly ... Can of worms?
- Previous message: [Python-ideas] Identity dicts and sets
- Next message: [Python-ideas] Identity dicts and sets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]