graphqllib icon indicating copy to clipboard operation
graphqllib copied to clipboard

More clean-ups

Open jhgg opened this issue 9 years ago • 5 comments

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).

jhgg avatar Sep 20 '15 03:09 jhgg

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.

dittos avatar Sep 20 '15 03:09 dittos

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.

jhgg avatar Sep 20 '15 03:09 jhgg

It definitely has some benefit, but I don't think that specifying __slots__ for a lot of classes is common practice in Python codebases.

dittos avatar Sep 21 '15 13:09 dittos

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!

jhgg avatar Sep 21 '15 13:09 jhgg

What do you want to do here @dittos?

jhgg avatar Sep 21 '15 18:09 jhgg