[Python-3000] PyInt_ to PyLong_ rename

"Martin v. Löwis" martin at v.loewis.de
Sun Dec 2 21:56:20 CET 2007


> longobject.h has still two PyInt_ functions: PyInt_GetMax and
> PyInt_CheckExact.
> 
> long
> PyInt_GetMax(void)
> {
>         return LONG_MAX;        /* To initialize sys.maxint */
> }
> It's only used for sys.maxint. Do we still need sys.maxint and
> PyInt_GetMax()? IMO PyLong_GetNativeMax() and sys.maxnativelong are
> better names.

I think they should go entirely. They don't give any interesting
information about the Python implementation.

> The name for PyInt_CheckExact is confusing, too. It's defines as
> PyInt_CheckExact(op) (PyLong_CheckExact(op) && _PyLong_FitsInLong(op)).
> PyLong_CheckFitsInLong() or PyLong_CheckNativeLong() (Georg's idea) do
> explain the meaning better.

No. It's not that the name is confusing - the implementation is.
PyInt_CheckExact tests whether the object is exactly the builtin
'int' type. Now that the original 'int' type is gone, it does not
make sense anymore to test for it - except that code does test for
it (which it should stop doing).

In most cases, PyInt_CheckExact was only used to determine whether
it is safe to invoke PyInt_AsLong; and the new definition of
PyInt_CheckExact has a good approximation for that case.

Regards,
Martin



More information about the Python-3000 mailing list