[Bf-committers] Precision and default range of IntProperty

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Oct 4 17:35:18 CEST 2013


On Fri, Oct 4, 2013 at 4:45 PM, IRIE Shinsuke <irieshinsuke at yahoo.co.jp> wrote:
> 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?

It's intentional. Blender is written in C/C++, and they used fixed
precision, variable precision would be quite difficult to add.

> 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.

Agreed, but this kind of thing is best reported in the bug tracker.

Brecht.


More information about the Bf-committers mailing list