[ovs-git] [openvswitch/ovs] 2c362f: Ensure significand remains an integer in Python3 j...

GitHub noreply at github.com
Wed Jun 8 18:42:31 UTC 2016


  Branch: refs/heads/master
  Home:   https://github.com/openvswitch/ovs
  Commit: 2c362f17d6f81b7602ac94abb7980fa1e6eb9cee
      https://github.com/openvswitch/ovs/commit/2c362f17d6f81b7602ac94abb7980fa1e6eb9cee
  Author: Terry Wilson <twilson at redhat.com>
  Date:   2016-06-08 (Wed, 08 Jun 2016)

  Changed paths:
    M python/ovs/json.py

  Log Message:
  -----------
  Ensure significand remains an integer in Python3 json parser

The / operation in Python 2 is "floor division" for int/long types
while in Python 3 is "true division". This means that the
significand can become a float with the existing code in Python 3.
This, in turn, can result in a parse of something like [1.10e1]
returning 11 in Python 2 and 11.0 in Python 3. Switching to the
// operator resolves this difference.

The JSON tests do not catch this difference because the built-in
serializer prints floats with the %.15g format which will convert
floats with no fractional part to an integer representation.

Signed-off-by: Terry Wilson <twilson at redhat.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: c63b04d678aab6e63551f4105d6fc03c195d639e
      https://github.com/openvswitch/ovs/commit/c63b04d678aab6e63551f4105d6fc03c195d639e
  Author: Terry Wilson <twilson at redhat.com>
  Date:   2016-06-08 (Wed, 08 Jun 2016)

  Changed paths:
    M Makefile.am
    M python/automake.mk
    A python/ovs/_json.c
    M python/ovs/json.py
    M python/setup.py

  Log Message:
  -----------
  Add optional C extension wrapper for Python JSON parsing

The pure Python in-tree JSON parser is *much* slower than the
in-tree C JSON parser. A local test parsing a 100Mb JSON file
showed the Python version taking 270 seconds. With the C wrapper,
it took under 4 seconds.

The C extension will be used automatically if it can be built. If
the extension fails to build, a warning is displayed and the build
is restarted without the extension.

The Serializer class is replaced with Python's built-in
JSON library since the ability to process chunked data is not
needed in that case.

The extension should work with both Python 2.7 and Python 3.3+.

Signed-off-by: Terry Wilson <twilson at redhat.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


Compare: https://github.com/openvswitch/ovs/compare/2f22698ff1c8...c63b04d678aa


More information about the git mailing list