[Python-Dev] API bloat

Mark Shannon marks at dcs.gla.ac.uk
Thu Feb 10 14:37:36 CET 2011


Nick Coghlan wrote:
> On Thu, Feb 10, 2011 at 8:16 PM, Mark Shannon <marks at dcs.gla.ac.uk> wrote:
>> Doing a search for the regex:  "PyAPI_FUNC\([^)]*\) *Py" in .h files,
>> which should match API functions (functions starting _Py are excluded) gives
>> the following result:
>>
>> Version  matches
>> 3.0       717
>> 3.1.3     728
>> 3.2b2     743
>>
>> It would appear the API  bloat is real,
>> not just an artefact of updated docs.
> 
> Since it doesn't account for #ifdef, a naive count like that isn't a
> valid basis for comparison.
> 
OK. How about this:

egrep -ho '#.*PyAPI_FUNC\([^)]*\)( |\n)*Py\w+' Include/*.h
finds no matches.

egrep -ho 'PyAPI_FUNC\([^)]*\)( |\n)*Py\w+' Include/*.h | sort -u

This finds all matches and removes duplicates, so anything defined
multiple time in branches of #ifdef blocks, will only be counted once.

Version  matches
3.0       714
3.1.3     725
3.2b2     739

So given, the revised numbers;

The "what's new for 3.2" API section:
http://docs.python.org/dev/py3k/whatsnew/3.2.html#build-and-c-api-changes
lists 6 new functions, yet 14 have been added between 3.1.3 and 3.2b2.


> I would hazard a guess that a substantial amount of the additional
> numbers there are going to be from new alternative definitions of
> Py_hash_t and some of the Py_UNICODE macros.

Unless there is a PyAPI_FUNC involved, these won't match the regex.

> 
> Cheers,
> Nick.
> 




More information about the Python-Dev mailing list