Skip to content

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

Open
@PallHaraldsson

Description

@PallHaraldsson

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.]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions