This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients eric.smith, gpolo, hagen, ncoghlan
Date 2008-12-19.22:01:31
SpamBayes Score 0.0015381092
Marked as misclassified No
Message-id <1229724094.5.0.319346230022.issue4701@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2008-12-19 22:01:34ncoghlansetrecipients: + ncoghlan, eric.smith, gpolo, hagen
2008-12-19 22:01:34ncoghlansetmessageid: <1229724094.5.0.319346230022.issue4701@psf.upfronthosting.co.za>
2008-12-19 22:01:32ncoghlanlinkissue4701 messages
2008-12-19 22:01:31ncoghlancreate