CharlieGroves, incept: 2006-11-16

Porting an existing Python module written in C into Java that Jython understands is a pretty straightforward task so it can serve as a good introduction to the Jython codebase. I'm going to explain how I'd go about porting the [http://www.python.org/doc/2.3.5/lib/module-csv.html csv] module here.

# Declare your intention to implement the csv module on the Jython dev list so no one else starts working on it. # Add a new class org.python.modules._csv.java in src. # Add "_csv" to the builtinModules array in org.python.modules.Setup # Run Lib/test/test_csv.py. Everything will fail since none of the csv methods are implemented yet. Now pick one of the simpler tests and start adding methods to csv to get it to work. _csv.java will be an implementation of the stuff in _csv.c from Python. All of csv_methods from _csv.c needs to be implemented as static methods in _csv.java. You can get an idea of how it's done from _codecs.java and _codecs.c or any of the module implementations in org.python.modules and their corresponding C implementation. As you add the methods to _csv.java, Jython will pick up on them and parts of the tests will start working. # Keep adding pieces to _csv.java till the tests pass # Submit a patch to the [http://www.jython.org/patches tracker]. # Revel in the glory of another implemented module

No one has taken csv yet, so it's available as a starting point. If you're not interested in comma separated values, run regrtest.py as described in the JythonDeveloperGuide. All of the skipped modules are unimplemented in Jython. Pick one of them and substitute its name for csv in the directions above.