[PyGreSQL] 64 bit int typecasting in pgdb module

true name truename42 at gmail.com
Tue Mar 4 08:13:13 EST 2008


Hi

pgdb module was casting my bigint types to longs, needlessly, since
I'm on a 64 bit architecture, so I replaced the line:
INTEGER = pgdbType('int2', 'int4', 'serial')

with the lines:
import sys
if sys.maxint == 9223372036854775807:
	INTEGER = pgdbType('int2', 'int4', 'serial', 'int8')
else:
	INTEGER = pgdbType('int2', 'int4', 'serial')

But really you don't even need to do this check, you can probably just
add int8 to that list:
INTEGER = pgdbType('int2', 'int4', 'serial', 'int8')

Or really, add all the non-float numeric types to the same
NUMBER/INTEGER type object, and rely on python's int() cast which will
return a long type for numbers that exceed the int range of the
architecture it's running on.


More information about the PyGreSQL mailing list