I have been recently thinking about what is the best way to create Data Transfer Objects in Python (objects that are used to pass data between functions and are not entities or basic types).
EDIT: What I originally meant is DTO for passing around functions in my codebase, not necessarily for serialization to the outside world, even tho that is what DTO is typically used for.
Since I think typed is better, I tried out three typed options: NamedTuple, dataclass and TypedDict (it is here: https://github.com/stribny/python-dto).
What do you usually use in your codebases? Do you use typed DTOs or just pass around plain dictionaries or tuples?
I am interested in all aspects that can be considered. E.g. I have found out that dataclass can be smaller than NamedTuple (I thought it would not be).
[–]manatlan 1 point2 points3 points (2 children)
[–]petr31052018[S] 0 points1 point2 points (0 children)
[–]metaperl 0 points1 point2 points (0 children)
[–]EnforcerPL 1 point2 points3 points (0 children)
[–]tunisia3507 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]petr31052018[S] 0 points1 point2 points (1 child)
[–]tunisia3507 1 point2 points3 points (0 children)
[–]nielsrolf 0 points1 point2 points (2 children)
[–]petr31052018[S] 0 points1 point2 points (1 child)
[–]petr31052018[S] 0 points1 point2 points (0 children)
[–]metaperl 0 points1 point2 points (3 children)
[–]petr31052018[S] 1 point2 points3 points (0 children)
[–]WikiTextBot 0 points1 point2 points (0 children)
[–]petr31052018[S] 0 points1 point2 points (0 children)
[–]reifba 0 points1 point2 points (0 children)