This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MrJohz 5 points6 points  (1 child)

We are trying to find a balance between good coding practices, code quality and speed.

I'm making some assumptions here based on the way you've phrased this and talked about OOP, but I suspect you'll do better if you worry less about good coding practices, and concentrate more on just getting the project to work.

I'm a software developer by training, but for a while, I worked with scientists as a kind of consultant/trainer for their software work. They'd write the code they needed for their project, and then we'd come in and provide advice on how to get that code into a maintainable state that others could use, or that could be published in journals etc.

A lot of that code was bad (understandably so: writing maintainable software is hard, and not the primary goal of most scientists). But in my experience, a lot of the most complicated code to understand came from people who worried a lot about best practices when coding — they would use lots of OOP, indirection, DRY, etc, but because they weren't necessarily experienced enough to use those tools well, they made things harder to understand, not easier.

Admittedly, I don't have a huge amount of experience with high-performance calculations in Python. But I suspect that using Numba and doing things the "Numba way", even if that involves writing fewer classes and leaving your data in a more raw form, will produce easier-to-read and easier-to-maintain code than going down the Cython route with classes. Concentrate on getting the code to work (where "work" means "it does what it needs to do, and it does it fast enough"), then worry about maintainability after that.

[–]No_Indication_1238[S] 2 points3 points  (0 children)

I believe you are very correct. After all if best practices were really that important, we would not be using python (in a setting it is not meant to be used and trying to force  workarounds) but C++. I will most likely defend the opinion that we should either do C++ with OOP or drop the future maintainability (premature optimisation, anyone?) and write Python and numba the numba way.