Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting objects; e.g. support dataclasses? #567

Open
PallHaraldsson opened this issue Oct 23, 2024 · 0 comments
Open

Converting objects; e.g. support dataclasses? #567

PallHaraldsson opened this issue Oct 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@PallHaraldsson
Copy link
Contributor

PallHaraldsson commented Oct 23, 2024

I think, though not sure, that dataclasses are very important in (modern) Python (supported in all current Python, i.e. since 3.7), and they basically map to Julia's structs (or well could), so do they need special support in this project? I don't see them in the table:

| `tuple` | `Tuple` |
| `collections.abc.Mapping` (inc. `dict`) | `PyDict` |
| `collections.abc.Sequence` (inc. `list`) | `PyList` |
| `collections.abc.Set` (inc. `set`, `frozenset`) | `PySet` |
| `io.IOBase` (includes open files) | `PyIO` |
| `BaseException` | `PyException` |
| `datetime.date`/`datetime.time`/`datetime.datetime` | `Date`/`Time`/`DateTime` |
| `datetime.timedelta` | `Microsecond` (or `Millisecond` or `Second` on overflow) |
| `numpy.intXX`/`numpy.uintXX`/`numpy.floatXX` | `IntXX`/`UIntXX`/`FloatXX` |
| **Standard priority (other reasonable conversions).** | |
| `None` | `Missing` |
| `bytes` | `Vector{UInt8}`, `Vector{Int8}`, `String` |
| `str` | `String`, `Symbol`, `Char`, `Vector{UInt8}`, `Vector{Int8}` |
| `range` | `UnitRange` |
| `collections.abc.Mapping` | `Dict` |
| `collections.abc.Iterable` | `Vector`, `Set`, `Tuple`, `NamedTuple`, `Pair` |

I do see Python also has namedtuples, an alternative, not clear to me if either supported. I see tuples are, and something gets converted to Julia's NamedTuples. And PyDict. Python dictionaries are ordered, so I think PyDict supports that (converting from; and to Python likely also not problematic), otherwise mapping to Dict, simply would have been chosen?

[I see Python has now an internal C API (not public API) to get UTF-8 data, so maybe something better could be done for passing strings back end forth.]

@PallHaraldsson PallHaraldsson added the enhancement New feature or request label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant