You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tl;dr the "subclass from dict" approach is more promising.
I just took a crack at using attrs to create pystac objects and wanted to write up some initial thoughts comparing that approach to the "subclass from dict" approach.
There are 3 main types of things stored on pystac objects:
data in pre-defined fields
data in arbitrary fields
other objects that aren't part of the spec, but are useful to have around (validator, reader)
The "subclass from dict" approach is very good at 2 and 3, but is less good at 1
The attrs approach is very good at 1, not good at 2 and ok at 3.
So I was originally thinking maybe we can do both! Subclass from dict and extend it using attrs. But that doesn't really work because one of the main things that attrs wants to do is write the __init__.
My main finding is that attrs feels like a nice way to implement a data model, but if we are trying to store other non-spec attributes on the class (I'm looking at things like _stac_io) it starts to be less nice.
Pros:
data model is the primary feature of the class
equality, repr, serialization are all included
Cons:
any attribute on the class that should not be serialized needs to be explicitly excluded (or be private)
there are some extra hoops to jump through for generic fields
The text was updated successfully, but these errors were encountered:
tl;dr the "subclass from dict" approach is more promising.
I just took a crack at using
attrs
to create pystac objects and wanted to write up some initial thoughts comparing that approach to the "subclass from dict" approach.There are 3 main types of things stored on pystac objects:
The "subclass from dict" approach is very good at 2 and 3, but is less good at 1
The attrs approach is very good at 1, not good at 2 and ok at 3.
So I was originally thinking maybe we can do both! Subclass from dict and extend it using attrs. But that doesn't really work because one of the main things that attrs wants to do is write the
__init__
.My main finding is that
attrs
feels like a nice way to implement a data model, but if we are trying to store other non-spec attributes on the class (I'm looking at things like_stac_io
) it starts to be less nice.Pros:
Cons:
The text was updated successfully, but these errors were encountered: