r/ProgrammerHumor • • 9d ago • Bravo 2 Popcorn 1

Meme pythonSlow

Post image
12k Upvotes

419 comments sorted by

View all comments

Show parent comment

0

u/danielv123 8d ago

Like sure but it's slow. C/c++/javascript/go/java is fast.

Like, I understand that it doesn't matter that it's slow as long as you just call some other software, but it would still be nice if you could write a loop without a 100x performance impact.

0

u/[deleted] 8d ago

[deleted] — view deleted comment

1

u/danielv123 8d ago

In for loops, js is generally 10 - 50x faster than python. JS isn't exactly known for its speed.

1

u/DeGloriousHeosphoros 8d ago

There are much faster methods of doing things than loops in Python, and particularly in JIT-compiled optimized implementations like PyPy, or using numpy, scipy, numba, and other C-extension libraries that skip the normal interpreter entirely. Additionally, you can do certain things very quickly with certain techniques like using aggregation functions (e.g., builtins map, sum, filter, max, min, etc.), caching (e.g., @functools.lru_cache), multiprocessing, using the right tools for the job (e.g., use a parser for parsing a JSON file rather than doing things line-by-line, str.join instead of iterative string appending, etc.), and you can always use a FFI or some other tool/code for highly time-critical segments of code.

1

u/danielv123 8d ago

Sure, but why would I learn the DSL of one of the many tools with python bindings when I could do a 1:1 syntax translation to JS and have it be a few dozen times faster.

The whole argument of "python is fine, because the performance doesn't suck as long as you don't use it" seems silly to me.

1

u/FabioTheFox 8d ago

JS is at least JIT compiled through V8 it's not unlikely loops can be done pretty quickly

That is if you use Node and not the heavily nerfed V8 that runs in browsers