3 ms·
Edit: The numbers have been revised by adding the missing -O3 The comment was based on what I saw by running an unoptimized C++ binary. You can repeat it yours
by adsharma 2y ago
Edit: The numbers have been revised by adding the missing -O3
The comment was based on what I saw by running an unoptimized C++ binary. You can repeat it yourself on your machine.
But yeah - in general, C++ can be 70x faster than python on many benchmarks, which is why tools that translate between languages exist.
- adsharma 2y agoIncluding the output of py2many --mojo=1 test.py here for completeness. The generated code didn't run out of the box. Slightly modified below: from python import Python fn main() raises: var json = Python.import_module("json") for i in range(100000): var file = open("test.json", "r").read() var data = json.loads(file) var wealth_str = data["user"]["wealth"] var wealth = Float64(wealth_str) print("OK") Not much faster: # time -p ./test OK real 1.69 user 1.16 sys 0.40 But you get a small shippable binary: # du -sh test 4.1M test