
On Sun, Aug 10, 2025 at 5:56 PM John Levine <johnl@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. Regards, Bill Herrin -- William Herrin bill@herrin.us https://bill.herrin.us/