The addition of varying fields
Description
I have thought of a new feature which could really benefit developers. So it would be good to have a msgspec class which has a "varying" field type. Meaning that if two instances have the same field and type but differ by the amount/repetition of that field, then they should be considered an instance of the msgspec class and of the same type. This would be useful in modelling situation when you have instance 1: field 1 : type y field2[0] : type x field2[1] : type x field2[2] : type x
And instance 2: field 1 : type y field2[0] : type x field2[1] : type x field2[2] : type x field2[3] : type x field2[4] : type x
And where the msgspec fields could be something like: field 1 : type y field2[varying] : type x
Why not use a simple list or tuple?
class Foo(msgspec.Struct):
field1: TypeY
field2: tuple[TypeX, ...]
Why not use a simple
listortuple?class Foo(msgspec.Struct): field1: TypeY field2: tuple[TypeX, ...] Annotating tuples
The types between the instances do not differ. But they differ by the number of a specific field of the same annotation type. I want msg spec to support such a case where there can be two instances, but one instance differs by the number of a specific field on the msg spec class. Where both instances are still considered an instance o the same msgspec class.
I want msg spec to support such a case where there can be two instances, but one instance differs by the number of a specific field on the msg spec class. Where both instances are still considered an instance o the same msgspec class.
@ApxMK thats what @floxay suggested .. can you close the request / or add more details if the suggested solution do not work for you.