3 ms·
this reminds me of a Perl guy once asking me why Python calls hashes dicts. I said that a dict is a key value object with a defined set of included methods. Th
by dec0dedab0de 4y ago
this reminds me of a Perl guy once asking me why Python calls hashes dicts. I said that a dict is a key value object with a defined set of included methods. The fact that it uses a hash under the hood is just an implementation detail. If a better technique comes along, Python is free to change it. Also If someone wanted to do something crazy like make an implementation of python where every dict was a nosql database, that would be fine as long as it implemented the same behavior.
For structs you have to remember that in python everything is reference passed, so some of the differences between structs and classes that you see in other languages do not apply.
But I suspect the real practical reason is that python already has structs, which are used for interoperability with C structs. Or any structured binary format really.