scipp / sciline

Build scientific pipelines for your data
https://scipp.github.io/sciline/
BSD 3-Clause "New" or "Revised" License
10 stars 2 forks source link

Result dictionary with ``str`` type keys #184

Open YooSunYoung opened 2 months ago

YooSunYoung commented 2 months ago

I had a feed back about sciline interface that it can be cumbersome to import all the types you need to retrieve results.

It might be helpful to have a helper function that turns dict[type, Any] into a dict[str, Any]...?

jl-wynen commented 2 months ago

This may not be as usable as you think. We would have to use the fully qualified names of types to avoid collisions:

>>> res = {int: 3, float: 4.1}
>>> toolz.keymap(sciline._utils.key_full_qualname, res)
{'builtins.int': 3, 'builtins.float': 4.1}

Is spelling out modules really better than importing names?

YooSunYoung commented 2 months ago

This may not be as usable as you think. We would have to use the fully qualified names of types to avoid collisions:

>>> res = {int: 3, float: 4.1}
>>> toolz.keymap(sciline._utils.key_full_qualname, res)
{'builtins.int': 3, 'builtins.float': 4.1}

Is spelling out modules really better than importing names?

No I don't think so. I much prefer using the dedicated type-object than string-keys.

But the original idea was not my opinion...

I opened it to see if anyone else has the similar feedback.