Message78071
OK, the discrepancy with bytearray turns out to be fairly
straightforward: bytearray overrides the comparison operations, so
inheritance of the default object.__hash__ is automatically blocked.
range() objects don't support comparison, so they inherit __hash__ when
PyType_Ready is called.
Which then begs the question of why range() instances are unhashable
only until something happens to invoke the tp_getattro slot on the type
object... and it turns out that PyType_Ready isn't called on the type
during interpreter startup. Instead, it only happens lazily when one of
the operations that needs the tp_dict to be filled in calls PyType_Ready
(the default dir() retrieves __dict__ from the type object, and this
attribute access causes PyType_Ready to be called).
Only at this point is the slot inheritance on the range() type
calculated correctly. |
|
Date |
User |
Action |
Args |
2008-12-19 22:01:34 | ncoghlan | set | recipients:
+ ncoghlan, eric.smith, gpolo, hagen |
2008-12-19 22:01:34 | ncoghlan | set | messageid: <1229724094.5.0.319346230022.issue4701@psf.upfronthosting.co.za> |
2008-12-19 22:01:32 | ncoghlan | link | issue4701 messages |
2008-12-19 22:01:31 | ncoghlan | create | |
|