brian2 icon indicating copy to clipboard operation
brian2 copied to clipboard

weave replacement for Python 3

Open thesamovar opened this issue 6 years ago • 6 comments

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?

thesamovar avatar Apr 26 '19 10:04 thesamovar

Hello @thesamovar, interested in doing this, can I work on this?

tapaswenipathak avatar Jul 16 '19 04:07 tapaswenipathak

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.

mstimberg avatar Aug 09 '19 13:08 mstimberg

Another option to consider is pybind11 and cppimport. Here's an example of how that looks: https://gist.github.com/thesamovar/707fb4c66471bdd7ccb8af8109957a49

thesamovar avatar Jan 31 '20 16:01 thesamovar

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.

thesamovar avatar Jan 31 '20 18:01 thesamovar

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

mstimberg avatar Feb 04 '20 10:02 mstimberg

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.

thesamovar avatar Feb 05 '20 17:02 thesamovar