-
Notifications
You must be signed in to change notification settings - Fork 91
DuckDBPyType.children should return a tuple, not a list #349
-
Unless mutability is needed internally, this would improve Datatypes on multiples areas, and would be a first step to a more in-depth future improvement of datatypes API.
- better performance and memory efficiency of tuples vs list
- possibility to type hint them more precisely. Since a lot of children types are of static length (list, decimal for example), tuples are just plain better than list to statically type.
- Later, the "know length" children could be returned as NamedTuples (if that's possible from the C++ side, I have experience with Pyo3 but not much with C++ ), improving the user experience.
I have already code that exist for this and would be happy to make a PR for the static typing side.
Also side note:
would be nice if JSON and BIGINT could be exposed as constant just like the other "simple" types.
https://github.com/OutSquareCapital/pql/blob/7a9f8ec00c55cd8d8c0eadd7dfb85ad6d1aa1dcc/src/pql/sql/_datatypes.py#L63
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Here's something you could use as a starting point on the typing:
We didn't end up using it, but (narwhals-dev/narwhals@b4e4980) shows where we would have
Beta Was this translation helpful? Give feedback.