brian2
brian2 copied to clipboard
weave replacement for Python 3
As noted in #1073 and #1074 Cython (the only low level codegen target for Python 3) is very slow to compile. It would be good to have a replacement. Some options are:
- Update weave for Python 3. This is potentially a lot of work (unsure, didn't check)
- Find an alternative library, like http://pyinline.sourceforge.net
- Write our own library
- Switch to having numba as our default codegen target (although this would require some benchmarking, and I'm in general a bit unsure about this option)
- Build on Cython but generating a C++ file and just using Cython to wrap it (which presumably means the Cython code generation step would be very lightweight?).
I think I would probably favour the last option - thoughts?
Hello @thesamovar, interested in doing this, can I work on this?
Hi @tapaswenipathak , sorry for taking for getting back to you about this. I think this issue is a really big one and still needs some discussion, it's probably not a good starting point for an external contributor at the moment.
Another option to consider is pybind11 and cppimport. Here's an example of how that looks: https://gist.github.com/thesamovar/707fb4c66471bdd7ccb8af8109957a49
Here's what it looks like doing it with Cython (probably not canonical way of doing it): https://gist.github.com/thesamovar/750d8b668470af27a41b4bab059513b9
Generates 7,500 line intermediate file, so may not be great for compilation speed.
I don't think it will be useful for us, but look at the sheer madness/brilliance of abusing the codec definition: https://github.com/georgek42/inlinec
I saw that! :-) We probably don't want to do that, but might be some useful bits for how to auto build an extension in there.