[Bf-committers] Precision and default range of IntProperty
IRIE Shinsuke
irieshinsuke at yahoo.co.jp
Fri Oct 4 16:45:08 CEST 2013
Hi devs,
In Python3, "int" type number has variable precision, but IntProperty
provides a fixed precision integer. So, if a Python script saves a
very large number in the intger property, the value may overflow and
cause unexpected results. Indeed, an error caused by such overflow
was reported in the tracker:
https://projects.blender.org/tracker/index.php?func=detail&aid=36857&group_id=9&atid=498
Why doesn't integer property use variable precision? Intentional?
One more thing,
The description of IntProperty says "... min=-sys.maxint, max=sys.maxint, ...".
Here, sys.maxint not existing in Python3 can be substituted with
sys.maxsize. However, IntProperty actually uses INT_MIN and INT_MAX
for the default range, and sys.maxsize is not same as INT_MAX.
On Ubuntu (64bit or 32bit),
sys.maxsize = 9223372036854775807 or 2147483647
INT_MAX = 2147483647
LONG_MAX = 9223372036854775807L or 2147483647L
LLONG_MAX = 9223372036854775807LL
We should correct the description or change the default range.
Thanks
--
IRIE Shinsuke
More information about the Bf-committers
mailing list