-
Notifications
You must be signed in to change notification settings - Fork 11
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
feature: add support for io operations from filenames #52
feature: add support for io operations from filenames #52
Conversation
6f4deaa
to
d79da4a
Compare
d79da4a
to
4f9dd41
Compare
RE performance concerns: given my findings in #42 I'd be surprised it came up on a profiler regardless of which route you go, since the vast majority of CPU time is spent in C++ ( |
Nice, this is a relief ! However the patch ended up increasing the complexity of your io functions much more than I anticipated, no hard feelings if you don't want it for this reason :) |
Had a quick look at your changes and they look fine to me, but ultimately it's up to @bobfang1992 since the python lib is his project, I'm just the shadowy C++ spectre looming in the shadows :) One concern I have is the addition of the (worth noting that I don't know how pybind11 handles strings; it's possible that it already ensures they're UTF-8?) |
Thank you, this is an excellent point that I failed to consider. Furthermore, quoting the spec (re: binary)
so It seems pretty clear to me that the encoding param should not be exposed in pytomlpp's api. I'll simplify my patch accordingly. |
I see that the wheels are failing to build because some of the tests that I added use |
Hi I fixed this in #53 can you rebase? |
83a7423
to
45ae9d4
Compare
Done ! |
I see no harm keeping them the way they are. I think we can merge this if the CI passes. |
Thank you ! |
fix #51
opening as a draft for now, I'll need to add tests
There's room for discussion over the exact implementation for this since no matter how it is handled, it will always add a slight overhead to the existing behaviour, either as an additional conditional check or a try/except.
The latter solution is particularly expensive (performance wise) if an exception is typically raised more than 1% of the time, so I went with the former, which should make both load and dump perform decently in any case, to no significant cost.
A side effect is that in order to achieve this properly, I had to add support to load/dump to and from binary files.