Live data from Hacker News

Show HN: Python can make 3M+ WebSocket keys per second

github.com

41–50 of 75 posts

Re: Show HN: Python can make 3M+ WebSocket keys per second

#41

> Show HN: Python can make 3M+ WebSocket keys per second > This article is about optimizing a tiny bit of Python code by replacing it with its C++ counterpart. So it's C++ rather than Python.

It’s cool that languages support this kind of stuff. So if you’re writing python the employs this technique and you still want to keep the “OS agnostic” characteristic of python does that mean you’d have to compile multiple C++ binaries and check the OS to see which one to run?

Yes, though hopefully it's been packaged up by the distro otherwise you'll end up having dependency problems if you compiled against a wrong libc or something else.

Re: Show HN: Python can make 3M+ WebSocket keys per second

#42

The hardest part of debugging Python is "hitting the wall" when you come to a native library (compiled C code). And Python has achieved a lot of speed-ups from Py2 to Py3 by adding more compiled C code. This is a real blocker for understanding the foundation library. On the other hand, in Java, with a few exceptions around Swing (native painting for GUIs) in Java, almost everything is written in pure Java, so you can…

> The hardest part of debugging Python is "hitting the wall" when you come to a native library (compiled C code).

This is one big reason I love Pharo and other Smalltalk-language implementations. Being mostly written in themselves down to the VM. You can take a deep dive and inspect everything without being afraid of smashing your head against C bedrock underneath. And they still manage doing this while being reasonably performant and dynamic.

Re: Show HN: Python can make 3M+ WebSocket keys per second

#43

> Show HN: Python can make 3M+ WebSocket keys per second > This article is about optimizing a tiny bit of Python code by replacing it with its C++ counterpart. So it's C++ rather than Python.

It’s cool that languages support this kind of stuff. So if you’re writing python the employs this technique and you still want to keep the “OS agnostic” characteristic of python does that mean you’d have to compile multiple C++ binaries and check the OS to see which one to run?

Alternatively, you could compile the C++ (or rust or zig) to WebAssembly, and a single binary would run anywhere.

Re: Show HN: Python can make 3M+ WebSocket keys per second

#44

The hardest part of debugging Python is "hitting the wall" when you come to a native library (compiled C code). And Python has achieved a lot of speed-ups from Py2 to Py3 by adding more compiled C code. This is a real blocker for understanding the foundation library. On the other hand, in Java, with a few exceptions around Swing (native painting for GUIs) in Java, almost everything is written in pure Java, so you can…

Likewise, in C#, almost everything is written in pure C#. It also gives you more control over memory allocations than Java, which is nice when trying to squeeze more performance out of the code.

Hopefully Java is getting value types and primitive types soon-ish.

Re: Show HN: Python can make 3M+ WebSocket keys per second

#45

> Show HN: Python can make 3M+ WebSocket keys per second > This article is about optimizing a tiny bit of Python code by replacing it with its C++ counterpart. So it's C++ rather than Python.

Yes, that's one of the ways one is supposed to optimize Python. Writing a tiny performance-sensitive part of a Python app in C/C++ is a possibility that many people do not think about when they decide they are going to develop the whole app in C/C++ and can be a much a smarter choice.

Re: Show HN: Python can make 3M+ WebSocket keys per second

#46

> Show HN: Python can make 3M+ WebSocket keys per second > This article is about optimizing a tiny bit of Python code by replacing it with its C++ counterpart. So it's C++ rather than Python.

Yes, that's one of the ways one is supposed to optimize Python. Writing a tiny performance-sensitive part of a Python app in C/C++ is a possibility that many people do not think about when they decide they are going to develop the whole app in C/C++ and can be a much a smarter choice.

In a way, but at this point your stack is Python/C++, where Python serves the role of a high-level language and C++ serves the role of the fast one. You're not optimizing Python-as-a-language at that point; you're FFIing to another codebase written in a different language.

So, if anything, the title should say "Python, when linked with C++ code, can make (...)"

Re: Show HN: Python can make 3M+ WebSocket keys per second

#47

Earlier quoted context omitted.

if you need speed ups like that, don't program in either. I strongly doubt any production C# code is significantly faster than its JAVA counterpart.

When it comes to languages you can draw up a loose hierarchy of potential performance where languages like C# and Java are vastly equivalent. Attempting to refine it any further descends into a bikeshedding farce.

Java is faster than C#, that's not "bike-shedding farce", that's a documented, and benchmarked fact

JSon serialization: 20+% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes...

Single query: 20+% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes...

Multiple query: 20+% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes...

Data update: 15% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes...

Re: Show HN: Python can make 3M+ WebSocket keys per second

#48

The hardest part of debugging Python is "hitting the wall" when you come to a native library (compiled C code). And Python has achieved a lot of speed-ups from Py2 to Py3 by adding more compiled C code. This is a real blocker for understanding the foundation library. On the other hand, in Java, with a few exceptions around Swing (native painting for GUIs) in Java, almost everything is written in pure Java, so you can…

Mojo seems like a very promising solution, despite it being AI oriented. Lex Friedman had a great podcast with the founder, its first version was released about a month ago, and in two weeks got 10k discord users. A superset of python that, once finished, can run all native python code, but also adds language features to get closer to the “metal”, getting speeds of C libraries with the ability to properly debug and s…

Crikey: LattBot strikes again! This guy's footprint on compilers and languages in one generation cannot be understated. His PhD work eventually grew into LLVM and Clang which lit a fire under GCC and MSVC. The C and C++ compiler ecosystem is now far more competitive and healthy.

He has the magic touch. What you describe sounds amazing. And having LattBot behind it is even better.

I have watched one of his episodes with Lex before. He is absurdly humble about his accomplishments.

Re: Show HN: Python can make 3M+ WebSocket keys per second

#49

Earlier quoted context omitted.

When it comes to languages you can draw up a loose hierarchy of potential performance where languages like C# and Java are vastly equivalent. Attempting to refine it any further descends into a bikeshedding farce.

Java is faster than C#, that's not "bike-shedding farce", that's a documented, and benchmarked fact JSon serialization: 20+% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes... Single query: 20+% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes... Multiple query: 20+% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes... Data update: 15% faster: https://www.te…

Why is this being downvoted? Sure the opening line isn't the most gentle, but these are some crazy benchmarks. I never saw this website before.

First link: How is it possible that Java can achieve same perf as C??? I write a lot of Java, and none of my stuff is close to C. I guess about 50% the speed -- which fine for my needs.

One reason (totally unscientific, of course) I think Java is faster: The virtual machine has been open source for longer. So more academics have looked at, run experiments, written papers... that are then read by the core Java team and sometimes implemented. C# is a bit behind, but should catch-up one day.

Re: Show HN: Python can make 3M+ WebSocket keys per second

#50

Earlier quoted context omitted.

When it comes to languages you can draw up a loose hierarchy of potential performance where languages like C# and Java are vastly equivalent. Attempting to refine it any further descends into a bikeshedding farce.

Java is faster than C#, that's not "bike-shedding farce", that's a documented, and benchmarked fact JSon serialization: 20+% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes... Single query: 20+% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes... Multiple query: 20+% faster: https://www.techempower.com/benchmarks/#section=data-r21&tes... Data update: 15% faster: https://www.te…

[deleted]
Post reply on HN