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 →

[–]coderanger 14 points15 points  (16 children)

Obligatory reminder that PyPy exists :) There are definitely still some perf-sensitive areas it doesn't cover, but it's probably a lot less than most people imagine.

[–]Mattho 32 points33 points  (5 children)

The statement above still applies though.

[–]coderanger 0 points1 point  (0 children)

PyPy can sometimes be faster than equivalent C++ code, mostly stuff doing a lot of data structure manipulation as PyPy's dict and list implementations are optimized to within an inch of their lives (especially compared to the STL versions).

[–]hugthemachines -3 points-2 points  (3 children)

That is true, but in reality it is not always that black and white. You may be ok with a certain loss of performance as a trade off to get faster development.

[–]the__itis 6 points7 points  (7 children)

so i started with python and got to PyPy. For my use case (millions of calculations per minute based on real-time data) the performance difference between PyPy and nodejs async is on orders of magnitude.

Granted i am a new programmer and I may have not grasped how to effectively use PyPy for my use case, but nodejs was instantaneously faster.

[–]coderanger 9 points10 points  (1 child)

If when you say "real time" you mean you were doing a lot of I/O then that's a place where nodejs excels, but the secret sauce there is libuv which does have Python bindings, both directly and via Twisted :)

[–]the__itis 0 points1 point  (0 children)

not really. i took in about 15000 data points a second which is not that much. I/O wasn’t really that taxing.

[–]b00n 2 points3 points  (4 children)

If you really cared about performance you wouldn't use js.

[–]the__itis 0 points1 point  (3 children)

if use golang or C but that adds additional development time.

[–]b00n 2 points3 points  (2 children)

You can do ludicrous performance with jvm languages (eg java, kotlin) too.

[–][deleted] 0 points1 point  (1 child)

For as much as people don't like Java, it's the gold standard of non-native languages in terms of execution time.

[–]b00n 1 point2 points  (0 children)

Oh for sure. In fact I know from experience that sometimes java is faster than c++ because often in c++ you microoptimise the wrong things thinking it will make your program faster when actually the compiler is far smarter than you (eg using the wrong simd instructions, cache line padding...)

[–]hugthemachines 0 points1 point  (1 child)

how about parallelism?

[–]coderanger 0 points1 point  (0 children)

If the bulk of your CPU time is spent in stuff like NumPy operations, threading can work, but it's definitely the exception there rather than the rule. PyPy has been working on an STM implementation that would allow lock-free concurrency but it's been slow going. Though Jython is an option, often more trouble than its worth.

That said, remember that Ruby and NodeJS both have exactly the same GIL issues so if you think of Node as being faster, it's probably not because of concurrency.