graphqllib
graphqllib copied to clipboard
More clean-ups
Add slots to classes where appropriate.
Also convert Loc dict to a Slotted Loc class to reduce memory usage further. Remove overly broad exception catching (which would just blow up later).
Hmm. I think we should add __slots__
only on the small objects that are created frequently (e.g. Token
, Loc
) It seems like too much to me.
More slots won't hurt. Slots do good in pretty much any situation IMO. Also kind of enforces a contract where extra stuff can't be tacked onto the built in types. Not that anyone would do that, but still.
It definitely has some benefit, but I don't think that specifying __slots__
for a lot of classes is common practice in Python codebases.
Perhaps not. But there are no downsides besides not being able to set attributes not defined in slots. Other than that. It just makes classes use less memory. Who says no to free memory!
What do you want to do here @dittos?