13 Build and C API Changes

Python PEP


13 Build and C API Changes

Some of the changes to Python's build process and to the C API are:

  • Three new convenience macros were added for common return values from extension functions: Py_RETURN_NONE, Py_RETURN_TRUE, and Py_RETURN_FALSE. (Contributed by Brett Cannon.)

  • Another new macro, Py_CLEAR(obj), decreases the reference count of obj and sets obj to the null pointer. (Contributed by Jim Fulton.)

  • A new function, PyTuple_Pack(N, obj1, obj2, ..., objN), constructs tuples from a variable length argument list of Python objects. (Contributed by Raymond Hettinger.)

  • A new function, PyDict_Contains(d, k), implements fast dictionary lookups without masking exceptions raised during the look-up process. (Contributed by Raymond Hettinger.)

  • The Py_IS_NAN(X) macro returns 1 if its float or double argument X is a NaN. (Contributed by Tim Peters.)

  • C code can avoid unnecessary locking by using the new PyEval_ThreadsInitialized() function to tell if any thread operations have been performed. If this function returns false, no lock operations are needed. (Contributed by Nick Coghlan.)

  • A new function, PyArg_VaParseTupleAndKeywords(), is the same as PyArg_ParseTupleAndKeywords() but takes a va_list instead of a number of arguments. (Contributed by Greg Chapman.)

  • A new method flag, METH_COEXISTS, allows a function defined in slots to co-exist with a PyCFunction having the same name. This can halve the access time for a method such as set.__contains__(). (Contributed by Raymond Hettinger.)

  • Python can now be built with additional profiling for the interpreter itself, intended as an aid to people developing the Python core. Providing ---enable-profiling to the configure script will let you profile the interpreter with gprof, and providing the ---with-tsc switch enables profiling using the Pentium's Time-Stamp-Counter register. Note that the ---with-tsc switch is slightly misnamed, because the profiling feature also works on the PowerPC platform, though that processor architecture doesn't call that register ``the TSC register''. (Contributed by Jeremy Hylton.)

  • The tracebackobject type has been renamed to PyTracebackObject.

13.1 Port-Specific Changes

  • The Windows port now builds under MSVC++ 7.1 as well as version 6. (Contributed by Martin von Loewis.)

See About this document... for information on suggesting changes.