I may be slow sometimes, but I'll get there in the end... On Tuesday 26 September 2006 12:16 pm, Jeremy Sanders wrote: > On Tue, 26 Sep 2006, Jeremy Sanders wrote: > > The python Ids appear to be large integer values, e.g. 183006915920, but > > when they are returned from internalId(), then they come back as negative > > values e.g., -1676677808L, which don't even appear to match the bit > > pattern of the original value. > > I'm afraid I'm replying to my own posting, but here is a short program to > demonstrate the issue: > > --------------------------------------------- > from PyQt4.QtCore import * > from PyQt4.QtGui import * > > class C(QAbstractItemModel): > pass > > a = C() > i = id(a) > index = a.createIndex(0, 0, i) > > print index.internalId(), i > --------------------------------------------- > > On 32 bit x86 this prints: > > -1208606100 -1208606100 > > On 64 bit x86_64 this prints > > -1788599016 182894994712 > > I couldn't see this mentioned in the mailing list archive.
This is the correct behaviour. On 64 bits int is 4 bytes and long and void* are 8 bytes. Python ints are actually C longs. The value of id() is greater than 4 bytes so you lose bits when you call createIndex(). Phil _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
