On 8/10/25 6:30 PM, William Herrin via NANOG wrote:
On Sun, Aug 10, 2025 at 5:56 PM John Levine <jo...@iecc.com> wrote:
It appears that William Herrin via NANOG <nanog@lists.nanog.org> said:
Python doesn't work this way. Its memory management is abstracted away
>from the programmer and the programmer does not control its precise
structure. For Python to access a DNS packet, the programmer must pack
and unpack an array of bytes using complex software of their own
devising. You can't just tell Python, "This is the complex data
structure these bytes contain, let me access the data without
unpacking it."
The python struct module is pretty fast, since it's written in C.
Hi John,

That's the difference. In Python you have a complex software library
which can shuttle data back and forth between Python's internal data
management process and an arbitrary byte-oriented data structure. In
C, that arbitrary data structure is a first class citizen in the core
language and no translation is needed.

You could pull apart a DNS packet in a Bash shell script if you really
wanted to. The code complexity would be out of sight and it would run
orders of magnitude slower than Python or C, but it can be done. Just
because a thing can be done doesn't mean the language is an optimal
choice for the task.

This is where native libraries come in. It's certainly not as good as fully native code, but they are honestly not that hard to write. As always, time to deployment is a consideration too. Raw compute cycles are pretty cheap these days. Throwing hardware at the problem is relatively easy, even if it causes ops guys eyes to roll.

Mike

_______________________________________________
NANOG mailing list https://lists.nanog.org/archives/list/nanog@lists.nanog.org/message/ZABBBVIYOFUXRKYO64QUBXJFILUPPM36/

Reply via email to