Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

srikiraju
Copy link
Contributor

@srikiraju srikiraju commented Apr 18, 2017

This PR tolerates protobuf 3.2+. Protobuf classes are supposed to end with _pb2 or protobuf may break in weird ways.

Additionally, the C++(cython?) implementation of protobuf behaves slightly differently from the python implementation(float handling). It seems that pip is allowed to pull whichever version it wants from pypi depending on the system.

Also fixes some tox environment issues.

@srikiraju
Copy link
Contributor Author

Could I get a review on this? @borntyping

value = dict(((a.key, a.value) for a in value))
elif descriptor.type == \
google.protobuf.descriptor.FieldDescriptor.TYPE_FLOAT:
value = round(value, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the special case for float values?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like rounding here made the tests pass, as the test value "11.1" has some float encoding precision loss.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to remove the test this breaks - I'm a little worried that this could break things in suprising ways for other users.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is still good, but maybe some thought should be put into what the precision of a text float should be (then instead of comparing things non-representable accurately by a python float, it can be compared via epsilon, e.g. | a - b | < some_small_value).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be fine (alternatively move the round() call to the test instead).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the C++ backend for protobuf results in floating point precision loss. Applications should be able to tolerate the IEEE 754 FP spec essentially.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll spend some time polishing the tests.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a PR that should fix this (and makes some needed changes anyway) here: #33. I'm merge it after this PR if you don't have any further changes, or close it if not needed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems much better!

@borntyping
Copy link
Owner

This looks great, thanks for all your work! My only issue is the float conversion mentioned above - if this is correct it could definitely use a comment explaining why in the code.

@efritz
Copy link

efritz commented Apr 26, 2017

This library currently conflicts with the protobuf requirement of gRPC (which requires >=3.2.0). This seems like a good solution.

Any chance this could move forward?

protobuf = 'protobuf>=3.0.0b2,<4.0.0'
protobuf = 'protobuf>=3.2.0,<4.0.0'
else:
protobuf = 'protobuf>=2.3.0,<4.0.0'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to bump this 3.2 as well, I was testing with python2.7 and 3.2+ only

@borntyping
Copy link
Owner

Thanks @srikiraju and @efritz! This has been released as 6.5.0, along with the changes in #33.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants