bobfang1992 / pytomlpp

A python wrapper for tomlplusplus
https://bobfang1992.github.io/pytomlpp/pytomlpp.html
MIT License
86 stars 10 forks source link

[toml::date] Make use of custom type caster support from pybind11 #26

Closed chaitan94 closed 4 years ago

chaitan94 commented 4 years ago

pybind11 has support for custom type casters. Check this for example on how to use: https://github.com/pybind/pybind11/blob/master/include/pybind11/chrono.h#L98

This PR, while it can be used directly in the current state, is more like a proof of concept for making use of this support. I implemented this only for casting toml::date objects - from/to python. @bobfang1992, @EpicWink If you guys like this approach, maybe we can start using it for other types as well. Let me know your thoughts.

Why this approach?

bobfang1992 commented 4 years ago

Hi, this is great. Do you plan to apply this to time and datetime etc in the same PR or that will be separate PRs? Thanks!

chaitan94 commented 4 years ago

I think let's have separate PRs for each so as to not make this a big change. That way we can have incremental changes. I will send in two other PRs one for time and one for datetime.

bobfang1992 commented 4 years ago

LGTM. I will merge it now if that's okay with you @chaitan94

chaitan94 commented 4 years ago

Sure, go ahead.