3 ms·
This doesn't surprise me, but take a look at the absolute numbers. In ANSI C on whatever processor he used, you can make over a billion function calls per seco
by nostrademons 12y ago
This doesn't surprise me, but take a look at the absolute numbers. In ANSI C on whatever processor he used, you can make over a billion function calls per second. Even in Python, you can do about 2 million.
Take a look at a profile of your program sometime. The vast majority of your functions get called maybe 20 times or less, with many of them being called only once (at startup) or once per operation (eg. setting up a request). Then there are obvious hot spots, eg. in many profiles I've run malloc() is by far the biggest single offender.
The Python strategy is to use Python as a scripting & glue language, and drop down into C for the critical parts of your program. You can get really far just writing initialization code in Python, keeping your data structures in C, and writing the inner loop of your algorithm or the critical part of your request processing in C.
- teacup50 12y ago... or, you could use a language that doesn't impose an extremely high, constant runtime cost overhead, and not have to write C at all.
- nostrademons 12y agoWhich one would that be? I've used C, C++, Java, Go, Haskell, and Ocaml, and they all (yes, even Haskell) result in prototyping slowdowns of 2x or more. Common Lisp is the only compiled language that I've felt can match or exceed Python/Ruby/Perl's development velocity, but it lacks many of the well-functioning batteries included with those scripting languages.
- codygman 12y agoHow much time did you spend with Haskell? I've spent a year or so with it and I feel like my productivity will catch up with Python (8~ years with it) eventually, though I could be wrong.
- S4M 12y agoI don't know how much time nostrademons spent in Haskell, but he wrote a nice tutorial for it: https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_...
- codygman 12y agoOh wow! Thanks for that tutorial. I wasn't aware nostrademons was the creator :)