[Python-Dev] Split unicodeobject.c into subfiles?

Victor Stinner victor.stinner at gmail.com
Thu Oct 4 22:30:07 CEST 2012


Hi,

I would like to split the huge unicodeobject.c file into smaller
files. It's just the longest C file of CPython: 14,849 lines.

I don't know exactly how to split it, but first I would like to know
if you would agree with the idea.

Example:
 - Objects/unicode/codecs.c
 - Objects/unicode/mod_format.c
 - Objects/unicode/methods.c
 - Objects/unicode/operators.c
 - etc.

I don't know if it's better to use a subdirectory, or use a prefix for
new files: Objects/unicode_methods.c, Objects/unicode_codecs.c, etc.
There is already a Python/codecs.c file for example (same filename).

I would like to split the unicodeobject.c because it's hard to
navigate in this huge file between all functions, variables, types,
macros, etc. It's hard to add new code and to fix bugs. For example,
the implementation of str%args takes 1000 lines, 2 types and 10
functions (since my refactor yesterday, in Python 3.3 the main
function is 500 lines long :-)).

I only see one argument against such refactoring: it will be harder to
backport/forwardport bugfixes.

Victor


More information about the Python-Dev mailing list