Skip to content

Instantly share code, notes, and snippets.

@pfreixes
Created June 8, 2018 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfreixes/bcdb11797655a36f5f91239666836674 to your computer and use it in GitHub Desktop.
Save pfreixes/bcdb11797655a36f5f91239666836674 to your computer and use it in GitHub Desktop.
JSON fallback for protobuf is so slow!
>>> timeit.timeit("""json.dumps({"name": "foo", "id":1})""", setup="from __main__ import json", number=10000)
0.04011281501152553
>>> timeit.timeit("json_format.MessageToJson(person)", setup="from __main__ import json_format, person", number=10000)
0.2599130409944337
>>> person
name: "foo"
id: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment