4 ms·
> There are plenty of pitfalls in leaky abstractions Sure, but this is a _massive_ pitfall. It's an optimization that can trivially make your code slower than
by weberc2 7y ago
> There are plenty of pitfalls in leaky abstractions
Sure, but this is a _massive_ pitfall. It's an optimization that can trivially make your code slower than the naive Python implementation, all due to a leaky abstraction.
> Regardless, any function that receives a ``list`` of ints will need to convert to an ndarray if it wants NumPy speed. If the function interface is modified later, I think it's fair to expect the editor to understand why.
Yeah, that was a toy example. In practice, the scenario was similar except the function called to a third party library that used Numpy under the hood. We introduced a ton of complexity to use this third party library on the grounds that "it will make things fast" instead of the naive list implementation, and the very next sprint we needed to update it such that it became 10X slower than the naive Python implementation.
That's the starkest example, but there have been others and there would have been many more if we didn't have the stark example to point to.
The current slogan is "just use Python; you can always make things fast with Numpy/native code!", but it should be "use Python if you have a deep understanding of how Numpy (or whatever native library you're using) makes things fast such that you can count on that invariant to hold even as your requirements change" or some such.
- xapata 7y agoI have mixed feelings about your conclusion. On one hand I don't want to discourage newbies from using Python. On the other, I enjoy that my expertise is valuable. It seems reasonable that different parts of the code are appropriate for modification by engineers of differing skills.