Open floxay opened 10 months ago
Sure, I think this is something we could support. This is unlikely to be much more efficient than if you passed in a list instead of a generator expression though - IMO the only real benefit here would be developer ergonomics not performance.
# This works today and is likely to be just as fast as if you used a generator expression
msgspec.convert([obj["data"] for obj in objs], type=list[Data])
Well, I do admit that I was hoping for some performance benefits by doing this. :P
Description
I often need to convert objects that are nested. I would like to skip creating a new list for this but this currently(?) does not seem possible.
Given this JSON:
and this Struct
I would like to do this: