-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add python bindings #188
Add python bindings #188
Conversation
373bc78
to
e696db2
Compare
b95d4c9
to
d5a0544
Compare
d5a0544
to
26db59d
Compare
Nice ! I am missing some docu like:
Testcases would also be nice. Perhaps you find a useful way for it. But docu is really required for the python libeconf user. |
bbfcd10
to
39ccacd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes, but mostly LGTM
from enum import Enum | ||
from dataclasses import dataclass | ||
from typing import * | ||
from ctypes import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not now. But in a future PR we should remove this and export the specific symbols.
c_key = _encode_str(key) | ||
if not isinstance(value, float): | ||
raise TypeError('"value" parameter must be of type float') | ||
c_value = c_double(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need here some approach for a "_ensure_valid_float(value)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because floats are saved as an exponentiation so we don't have to worry about the overflow. The typecheck should be enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhmm no. The exponentiation is because IEEE 754. In any case should not be required because a Python float is a C double:
>>> sys.float_info
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
The max match the one that from C and C++
07625ca
to
e8ad743
Compare
e8ad743
to
5fb87cc
Compare
This PR adds python bindings for libeconf to be included in the library