[Python-3000] Looking for advice on PEP 3101 implementation details

Eric Smith eric+python-dev at trueblade.com
Tue Aug 21 02:18:42 CEST 2007


I'm basically done with format(), string.format(), object.__format__(), 
string.__format__(), long.__format__(), and float.__format__().  I have 
some cleanup left to do from all of the refactoring, but it's passing 
the vast majority of my tests.

The only real remaining work is to implement string.Formatter.  This is 
a class designed to be overridden to customize the formatting behavior. 
  It will share much of the C code with string.format().

My plan is to write this class in Python, and put it in Lib/string.py.
Given the complexities and book-keeping involved, writing it in C
doesn't seem worth the hassle.  In order to talk back to the C
implementation code, I'll create a private module in Modules/_formatter.c.

Does this seem reasonable?

If so, my question is how to add module in the Modules directory.  There 
is some logic in the top level Makefile.pre.in, but it doesn't look like 
it applies to all of the code in Modules, just some of the files.

Modules/Setup.dist contains this comment:
# This only contains the minimal set of modules required to run the
# setup.py script in the root of the Python source tree.

I think this applies to me, as setup.py indirectly includes string.

So, is the right thing to do to insert my _formatter.c into 
Modules/Setup.dist?  Is there anything else I need to do?  Is there some 
existing code in Modules that I should base my approach on?

I googled for help on this, but didn't get anywhere.

Thanks again for your assistance.

Eric.





More information about the Python-3000 mailing list