[Cython] CmdLine.py refactoring

Stefano stefano.k.sanfilippo at gmail.com
Mon Aug 8 22:36:13 CEST 2011

Sunday 7th August 2011 16:21:06, Stefan Behnel wrote:
> argparse is new and not supported by anything but 2.7 and recent 3.x
> versions. Cython currently runs on Python 2.4, which rules out a dependency
> on argparse. I never tried it, so I can't tell what exactly the advantages
> over optparse are. They certainly can't be big enough to make up for a
> duplicate implementation of Cython's cmd line parser.

Work on commandline is almost over, then I'll expose my refactoring proposal 

Working with argparse vs. optparse showed me that, indeed, the two things are 
much different (and, in this sense, argparse is more straightforward than 
optparse), moreover that the optparse (nor the old if: elif: approach) version 
cannot parse complicated commandlines (see Tests/TestCommandLine.py)  - a 
thing which we may expect with some exoteric build system producing 10-line-
long command lines (a.k.a. autotools) . 

As a proof of its quality, Fedora, Ubuntu and SuSe all ship a python-argparse 
package for older versions of python (<2.7). Given that the module is self-
contained and as small as 80KB, wouldn't be feasible to add it as a build 

So that I could drop the alternate implementation - which, sadly, makes one of 
the tests from the testsuite (apart from my own) fail.

Find all commits at: https://github.com/satufk/cython/commits/_commandline


More information about the cython-devel mailing list