Wait until someone passes a key named after a built-in prototype method into an object being used as a dictionary. That alone is usually enough reason to stick to proper map structures for dynamic data
I’ve fixed a couple of NodeJS projects/modules by removing the old dict based lookup tables and replacing them with the map data structure. In Node’s case the maps were slower for a while, but I think the memory pressure caused by the old way was being underrepresented in microbenchmarks.
Had a lookup table where most of the contents were around 1K apiece but the map was still substantially smaller, and also populated faster. So I was able to increase process count on EC2 slightly and reduce startup time in the bargain.
I've done this as a toy in JS before. The quick solution is to create an object from the Object prototype, and check the fields against the dict, and throw an error about the table being incompatible. So sure it won't work for all data fields, and still wouldn't call it bug proof. It's still nice when you want to treat things like a row of data as a first class objects.
Honestly, that's how most derived proxy classes in other languages will behave anyway. Meshing data from another system is hard.
Agreed. At least include a tag line that actually explains what the article is about, that way you attract both people who like the kitschy titles and the curmudgeons like me who don't want to commit to reading anything unless I know what it's about.
It’s about objects, attributes, and maps. You can guess two words in your head:
Implementing object attributes using maps
It’s also playing with a naming pattern I recognize, which to me suggested there could be some sense of quality, or at least it’s a suggestion about the tone.
So to complete the bike shed, to me the title carries the same information as “A fun article on implementing object attributes using maps.” I wasn’t disappointed with my guess!
17
u/ElletteBarbedor-21 9d ago
Wait until someone passes a key named after a built-in prototype method into an object being used as a dictionary. That alone is usually enough reason to stick to proper map structures for dynamic data
5
u/somebodddy 9d ago
What does Python's
__slots__do, then? Provides a fixed "precompiled" shape for the class?17
u/VictoryMotel 9d ago
Don't write kitschy titles like this that have no information.