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

Meme pythonSlow

Post image
12k Upvotes

421 comments sorted by

View all comments

Show parent comment

6

u/thefireskull 7d ago

javascrip is fast.

loop without a 100x performance impact.

Is this JS hyper fast loop in the room with us?

1

u/danielv123 7d ago

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

1

u/DeGloriousHeosphoros 7d 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 7d 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 7d 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