News for hackers. Stuff that matters.
Re:Show HN: Python can make 3M+ WebSocket keys per second by phoe-krk on Monday July 03, 2023 @07:56AM (#36571670)
> 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.

Re:Show HN: Python can make 3M+ WebSocket keys per second by sdiepend on Monday July 03, 2023 @08:15AM (#36571824)
The article was posted by "cprogrammer1994", that should've been a hint!
Re:Show HN: Python can make 3M+ WebSocket keys per second by phoe-krk on Monday July 03, 2023 @08:39AM (#36572061)
The first "C" stands for "Cython".

/s

Re:Show HN: Python can make 3M+ WebSocket keys per second by cprogrammer1994 on Tuesday July 04, 2023 @05:00AM (#36584055)
C stands for, well, C :) also, I do not use Cython.
Re:Show HN: Python can make 3M+ WebSocket keys per second by keithalewis on Monday July 03, 2023 @08:09AM (#36571773)
Bingo.
Re:Show HN: Python can make 3M+ WebSocket keys per second by sovietmudkipz on Monday July 03, 2023 @10:04AM (#36573021)
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?

Re:Show HN: Python can make 3M+ WebSocket keys per second by lukevp on Monday July 03, 2023 @10:37AM (#36573521)
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 by rat9988 on Monday July 03, 2023 @11:59AM (#36574805)
WWouldn't you lose some of the performance benefit?
Re:Show HN: Python can make 3M+ WebSocket keys per second by sovietmudkipz on Monday July 03, 2023 @03:02PM (#36577426)
Thanks for this. This is something I wouldn’t have considered.
Re:Show HN: Python can make 3M+ WebSocket keys per second by yw3410 on Monday July 03, 2023 @10:21AM (#36573285)
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 by jcarrano on Monday July 03, 2023 @10:48AM (#36573685)
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 by phoe-krk on Monday July 03, 2023 @10:51AM (#36573738)
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 (...)"