Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a great way to handle this situation?
views:
643answers:
6If you do find you need to write unique code for an environment, use pythons
import mymodule_jython as mymodule
import mymodule_cpython as mymodule
have this stuff in a simple module (''module_importer''?) and write your code like this:
from module_importer import mymodule
This way, all you need to do is alter module_importer.py
per platform.
@Daren Thomas: I agree, but you should use the platform module to determine which interpreter you're running.
I write code for CPython and IronPython but tip should work for Jython as well.
Basically, I write all the platform specific code in separate modules/packages and then import the appropriate one based on platform I'm running on. (see cdleary's comment above)
This is especially important when it comes to the differences between the SQLite implementations and if you are implementing any GUI code.
The #1 thing IMO: Focus on thread safety. CPython's GIL makes writing threadsafe code easy because only one thread can access the interpreter at a time. IronPython and Jython are a little less hand-holding though.
I'm pretty sure you already know this but unfortunately Jython can't load c extension modules.
There are two major issues at play here...
Firstly, to my knowledge, only CPython has RAII - you have to close your own resources in Jython, Ironpython, etc.
And Secondly, as has been mentioned, is thread safety.