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
Is your feature request related to a problem? Please describe.
It would be useful to support serialization and parsing of slice objects.
For example,
@dataclass
class Foo(DataClassMessagePackMixin):
my_slice: slice
slice_dict: dict[slice, int] # Legal in Python 3.12
f = Foo(slice(0, 5), {slice(3,6,2): 4})
s = f.to_msgpack()
Foo.from_msgpack(s)
Describe the solution you'd like
Slices should be natively serializable and parsable. The snippet above should run.
Describe alternatives you've considered
It's possible to hand write a slice wrapper class. This is what I've been doing but as slice has become hashable in Python 3.12, it would be nice to not have to have a non-trivial wrapping and unwrapping layer.
Additional context
This could be a good first issue as slices can basically be represented as tuples.
The text was updated successfully, but these errors were encountered:
Sounds good to me. A slice object can be represented as a list of [start, stop, step] values. Assuming, that these values can be either integer or None, this would be trivial to implement.
However, I will note that neither a list nor a tuple can be used as dictionary keys, so it cannot be a key in MessagePack format.
Is your feature request related to a problem? Please describe.
It would be useful to support serialization and parsing of slice objects.
For example,
Describe the solution you'd like
Slices should be natively serializable and parsable. The snippet above should run.
Describe alternatives you've considered
It's possible to hand write a slice wrapper class. This is what I've been doing but as slice has become hashable in Python 3.12, it would be nice to not have to have a non-trivial wrapping and unwrapping layer.
Additional context
This could be a good first issue as slices can basically be represented as tuples.
The text was updated successfully, but these errors were encountered: