Live data from Hacker News

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

github.com

11–20 of 75 posts

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

#11
post #6

Earlier quoted context omitted.

Do you think that relying less in C code could be better for Python and it’s community? I mean less focus on being “glue” between C code and more focus con optimizing the interpreter?

It is unlikely people would use Python if it didn't rely on C code. If your ML model takes hours when it can take minutes, or takes days when it can take hours, you will move away. You could move away to another language or a faster interpreter but that's a different discussion. > more focus con optimizing the interpreter This is good but there's an upper bound to performance of interpreted languages. Maybe the Pytho…

> If your ML model takes hours when it can take minutes, or takes days when it can take hours, you will move away. You could move away to another language or a faster interpreter but that's a different discussion.

How much of this is done in Python, vs constructing instructions in Python to run on a GPU at uber speed?

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

#12
post #6

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…

Do you think that relying less in C code could be better for Python and it’s community? I mean less focus on being “glue” between C code and more focus con optimizing the interpreter?

If you asked me, Python not only shouldn't rely on (third-party) C library code, but it shouldn't even be used for cases where pure Python is not optimal.

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

#15

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…

Are python debuggers really unable to integrate with something like GDB? I have no problem debugging native calls from Java. During development I've never seen a case where library source was unavailable. Even proprietary components from other companies come with source included.

I feel it’s less about instrumentation but more about Python developers understanding C code.

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

#16
This has nothing to do with websockets and much more with doing hashing and Python-to-native calls. It's comparing generating base64(sha1(something)) in Python which I suppose also means "websocket keys".

I'm not sure why the author implemented SHA1 and a base64 digest thereof manually rather than including a small library, but perhaps that was part of the challenge.

Python can generate a whole lot more keys per second if you enable SIMD, multithreading, or even GPU support. In fact, Ryzen / 11th+ Gen Intel/ARMv8A have dedicated SHA1 instructions that should significantly boost performance here. Together with something like https://github.com/WojciechMula/base64-avx512 I bet you could increase the performance an order of magnitude if daw CPU speed were really a concern.

I suppose three million keys per second ought to be enough for any websocket server, especially for a relatively simple implementation of the code.

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

#17
post #6

Earlier quoted context omitted.

Do you think that relying less in C code could be better for Python and it’s community? I mean less focus on being “glue” between C code and more focus con optimizing the interpreter?

If you asked me, Python not only shouldn't rely on (third-party) C library code, but it shouldn't even be used for cases where pure Python is not optimal.

Right, Python is the new Perl and people are misunderstanding what that means.

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

#18

Earlier quoted context omitted.

It is unlikely people would use Python if it didn't rely on C code. If your ML model takes hours when it can take minutes, or takes days when it can take hours, you will move away. You could move away to another language or a faster interpreter but that's a different discussion. > more focus con optimizing the interpreter This is good but there's an upper bound to performance of interpreted languages. Maybe the Pytho…

> If your ML model takes hours when it can take minutes, or takes days when it can take hours, you will move away. You could move away to another language or a faster interpreter but that's a different discussion. How much of this is done in Python, vs constructing instructions in Python to run on a GPU at uber speed?

Widely used libraries for python such as SciPy, PyTorch, TensorFlow, Numpy all drop down to lower level languages (C/C++/Fortran).

I haven't seen many people doing ML in Python without one of these libraries, so I'd say it is mostly constructing instructions in Python and offloading the actual intensive work to these libraries (which may or may not run on GPU depending on your hardware).

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

#20

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…

On the other hand, you still have to learn and use Java. I think learning Python and a touch of C is easier than trying to learn Java. Heck I'd go so far as to say C is a lot easier than Java. Frankly I don't understand why having to learn a little bit of C to debug a python program is such a red flag or wall to you, considering the sheer amount of learning one has to do to use Java at all. You're setting up an uber-sophisticated IDE to debug "ancient auth packages" instead of just... learning a little C and potentially fixing an up-to-date and beloved library?
Post reply on HN