[Python-Dev] Split unicodeobject.c into subfiles? (original) (raw)
M.-A. Lemburg mal at egenix.com
Fri Oct 5 09:27:17 CEST 2012
- Previous message: [Python-Dev] Split unicodeobject.c into subfiles?
- Next message: [Python-Dev] Tru64 support
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Victor Stinner wrote:
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/modformat.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/unicodemethods.c, Objects/unicodecodecs.c, etc. There is already a Python/codecs.c file for example (same filename).
Better follow the already existing pattern of using "unicode" as prefix, e.g. unicodectype.c and unicodetype_db.h.
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.
When making such a change, you have to pay close attention to functions that the compiler can potentially inline. AFAIK, moving such functions into a separate file would prevent such inlining/optimizations, e.g. the str formatter wouldn't be able to inline codec calls if placed in separate .c files.
It may be better to split the file into multiple .h files which then get recombined into the one unicodeobject.c file.
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Oct 05 2012)
Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
2012-09-27: Released eGenix PyRun 1.1.0 ... http://egenix.com/go35 2012-09-26: Released mxODBC.Connect 2.0.1 ... http://egenix.com/go34 2012-09-25: Released mxODBC 3.2.1 ... http://egenix.com/go33 2012-10-23: Python Meeting Duesseldorf ... 18 days to go
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/
- Previous message: [Python-Dev] Split unicodeobject.c into subfiles?
- Next message: [Python-Dev] Tru64 support
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]