Nick Coghlan <ncogh...@gmail.com> added the comment: 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. _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4701> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com