The good news is that other C macros are now documented as well! https://docs.python.org/dev/c-api/intro.html#useful-macros
If you look at Include/pymacro.h there are even more crazy macros which are not documented yet, like Py_BUILD_ASSERT(). I like Py_ARRAY_LENGTH() which gives the length of an array and not its size in bytes. The macro is nice because it fails with a compilation error if the argument is not an array! For example, it fails on "char *not_an_array" or "char not_an_array_neither[];". Victor 2017-09-15 20:59 GMT+02:00 Barry Warsaw <ba...@python.org>: > I landed bpo-31338 / PR #3374 which adds a Py_UNREACHABLE() macro to master, > along with some additional documentation in the C API describing this and a > few other common macros. If you’re writing or reviewing C changes that > include unreachable code paths, please use this macro for consistency, > instead of other approaches like assert() (which can be compiled out) and > `return NULL`, etc. > > As part of the PR, I changed a bunch of existing instances in the code: > > https://github.com/python/cpython/pull/3374/files > > If you find any cases I’ve missed, feel free to submit a PR and I will > happily review it. I think this makes our code more consistent and > ultimately safer. > > (Thanks Victor for the PR review!) > > Cheers, > -Barry > > > _______________________________________________ > python-committers mailing list > python-committers@python.org > https://mail.python.org/mailman/listinfo/python-committers > Code of Conduct: https://www.python.org/psf/codeofconduct/ > _______________________________________________ python-committers mailing list python-committers@python.org https://mail.python.org/mailman/listinfo/python-committers Code of Conduct: https://www.python.org/psf/codeofconduct/