Open Dowwie opened 5 years ago
Cool. Will look into this, especially since Python is my second favorite language to play around with. Definitely seems like this kind of functionality in Python is probably written in C, not Python itself, in which case one would expect it to be pretty fast. Perhaps I can learn something from their implementation, though. In any case, thanks!
Hey Brian I watched you present at RustNYC. Cool project.
I was curious how num_format performed relative to Python and so put together a tiny benchmark to find out. It seems that non-buffered num_format is approximately on par with that of standard string formatting in Python, formatting 1_000_000 at roughly 54ns median with Python 2 whopping nanoseconds faster at 52ns median. However, num_format benches buffered at 30 picoseconds. Nice. :+1:
I didn't study the source in Python but maybe it's making good use of an underlying C library and CFFI. Rust is usually at least 10x faster than CPython so it could likely be that. Any how, here's how you can verify on your own. You simply need to install the perf library for python using pip:
run this at the command line, assuming you've named the above code pyformat.py:
and to get more summary stats, once you have the result.json file:
see you at a future meetup
-Darin