[ovs-dev] Working on C wrapper for Python JSON parsing

Ben Pfaff blp at ovn.org
Fri May 6 15:30:38 UTC 2016


On Wed, May 04, 2016 at 04:12:45PM -0500, Terry Wilson wrote:
> I currently have a patch that adds a C extension module to wrap the
> in-tree JSON parser. It works with both Python 2 and 3. The
> performance increase is quite large. For example, parsing a 100Mb JSON
> file:
> 
>   Without extension: 273 seconds
>   With extension: 3.7 seconds

Wow, that's great!

> On the object->string side, I've tried to just replace the _Serializer
> class and to_{stream, file, string} with using Python's built-in
> json.dumps, since we don't have to worry about streaming when going
> from object->string. The problem is that there are 8 tests related to
> float handling that yield slightly different output. In each case, it
> looks like Python's version returns slightly more precise results. The
> existing implementation also seems to convert from things like 1e-9999
> to 0 whereas Python's converts to 0.0. None of these differences
> should really matter.
> 
> I'd like to avoid having to wrap the serialization stuff when there is
> something else that already works and is better, but if I have to I
> will. Just looking for opinions on what I should do. Here's the test
> failure output:

Both forms of output look acceptable to me; I don't see a reason to
require wrapping.  I'd adjust the tests rather than the output.



More information about the dev mailing list