3 ms·
For that stuff, yeah you're correct. What I've seen is issues with the implementation of those libraries in a project. I don't remember exactly, but I was pla
by bongodongobob 3y ago
For that stuff, yeah you're correct.
What I've seen is issues with the implementation of those libraries in a project.
I don't remember exactly, but I was playing with someone's wrapper for some kind of machine learning snake game and it was taking way longer than it should have on back of the napkin math.
The issue was using either a dict or a list in a hot loop and changing it to the other sped it up like 1000x.
So it's easy to think "yeah this library is optimized" but then you build something on top of it that is not obviously going to slow it down.
But, that's the Python tradeoff.
- 0cf8612b2e1e 3y agoThat sounds irrelevant to Python and just a matter of slow code cropping up in libraries until someone runs a profiler.
- littlestymaar 3y agoBut then again if your program have places where choosing the right Python primitive is important for performance, then using python is affecting performance here since even the best algorithm in Python would be slower than the equivalent C. Most of the time it doesn't matter because there's nothing hoy on the Python side, but if there is, then Python is going to be slowing your stuff down.
- hcarvalhoalves 3y ago> The issue was using either a dict or a list in a hot loop and changing it to the other sped it up like 1000x. The programmer using the wrong data structure is not a problem with the language.
- CamperBob2 3y agoIt really is with Python. There are simply too many containers and container-like concepts. Lists, arrays, sets, dicts...
- 0cf8612b2e1e 3y agoWhat modern language doesn’t have those? Go kind of cheats and has maps play double duty as sets.
- bongodongobob 3y agoKinda. I guess my native tongue is C/C++ and I wouldn't expect such a huge performance difference when using an array vs a linked list or something. It's not like I had millions of items in that structure either, it was like 100. I think it contained the batch training data from each round. I tried to find the project but couldn't. I was just shocked that there was such a huge difference between primitive data structures. In that situation, I wouldn't have guessed it would make a difference.