I've realized that this appears to be a limitation of old-style classes. New-style classes (ones that derive from object
) behave as expected:
class Foo(object):
#...
Results:
>>> f = Foo()
>>>
>>> f[0x80000000:0x90000000]
key.start = 0x80000000 key.stop = 0x90000000
'268435456'
>>>
>>> f[0xFEDCBA98 : 0x1200000000]
key.start = 0xFEDCBA98 key.stop = 0x1200000000
'73033532776'
>>>
I haven't seen this documented anywhere. It's especially confusing, since this limitation is not in the slice
class itself:
>>> s = slice(0xFEDCBA98, 0x1200000000)
>>>
>>> s
slice(4275878552L, 77309411328L, None)
>>>
>>> hex(s.start)
'0xfedcba98L'