1) write everything in python because its easy and quick to do so.
2) its slow as.
3) abandon software and write it in something else, or, live on with slow ass software and blame python for being slow and rubbish forever more.
re-writing python in c is a hideously painful process, and its proven to be very unsuccessful practically.
Writing new code in c/c++/whatever and exposing a python api is where successful projects like numpy and tensorflow live.
python is very good at what it is, but no one is ever going to go and rewrite your python code in c to make it faster; its just going to be slow forever.
1) write everything in python
2) yeah, the performance here is good enough so ship it
3) there is no 3
There are very few situations where performance is going to be an issue for you where there is not an existing C module solution that will solve the problem for you. The tired old 'python is slow' trope is getting more and more irrelevant every day. There are other aspects of the language that may make it a mediocre solution to the problem at hand, but out in the real world most people are simply getting the job done with python.
We certainly shipped (using django) and it was certainly slow, and remains a painfully slow very successful enterprise app.
I’m not arguing that the slowness is deal breaking, but it is slow, and it does, routinely, break the SLAs its supposed to meet.
So... unusably slow? no.
...but slow? yes, it really is.
imo. your milage may vary. /shrug
If there are performance issues, rewriting part of a Python application in C is much less likely than refactoring it, without using other languages, to use an existing high performance library.
Application-specific Python extensions are usually intended to allow scripting of the application, with little concern for Python performance (which is the same as doing the same thing without scripting).
New foreign language Python extensions are usually found in new Python libraries, to make existing proven C or C++ libraries available to Python applications or to improve on existing Python libraries.
It's a miracle they shipped it at all.
You can ship your own clone of Reddit next week, with blazingly fast code, running on two tiny VMs and supporting more load than Reddit, but would it be successful?
https://hackernoon.com/which-is-the-fastest-version-of-pytho... has a benchmark that includes 3.7.
With C being an incredibly difficult language to get right.
So difficult that languages like Go and Rust were invented.
In almost 20 years, I did it once. And it wasn't really needed, but I wanted to know how much it'd be improved.
Rather real world Fortran, C and C++ with Python glue code.
Just like Tcl, Ruby or whatever scripting language with the same glue code would get out of it.
Two languages to learn. Two languages to support. Two development environments. Two build tools. Two CI/CD pipelines. Two testing infrastructure. Two sets of code and security reviews.
Double the complexity and for what exactly ?
That's why Sun's "100% Pure Java TM" campaign and negligent support of integrating Java with native code was so misguided.
Software development is a process. You implement your MVP in one language, then measure its performance with real customers, then incrementally rewrite the hotspots and plug in optimized native libraries as necessary. The language ecosystem and culture should support and encourage that (like C#, Python, TCL and Lua do in spades), not fight against it and condemn you as a mongrel infidel if you dare to miscegenate with other languages.
Sun made a grave mistake with their linguistic supremacist "100% Pure Java TM" propaganda campaign: you should rewrite all of your code in Java instead of expecting Sun to provide you with easy seamless interoperability with existing languages and libraries.
So Sun's JNI and applet web browser integration languished while Microsoft integrated COM and CLR and P/Invoke for seamless interoperability with the web browser and other languages like C++ into Java and CLR. And the insipid influence of "100% Pure Java TM" persists even today (have fun using Android NDK).
Sun also had an unholy obsession with code generation, since their attitude was to breed as much "100% Pure Java TM" Code into the world as possible (see AspectJ, JAXB, etc). While C# took a much better approach of supporting code annotation and metadata and reflection and bytecode generation at runtime so you didn't actually have to generate and compile a huge pile of boilerplate source code (see P/Invoke).
https://docs.microsoft.com/en-us/cpp/dotnet/how-to-call-nati...
And of course Oracle is delighted to continue pushing "100% Pure Java TM":
https://www.oracle.com/technetwork/java/100percentpurejavaco...
>[...] 100% Pure Java, JavaStar, JavaPureCheck, [...] JavaSpin, HotJava, The Network Is The Computer, and JavaStation are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and certain other countries.
Registering purity as your trademark and insisting that all of your users rewrite every bit of their existing legacy code in your pure language, and never use or talk to any other languages ever again, always seemed like separatist linguistic supremacy to me.
Apparently, C#'s P/Invoke is an evil impure cross-language conspiracy to dilute our linguistic purity and sap our precious bodily fluids, breeding caravans of mongrel coders who will swarm across our open borders and steal our jobs. That's why JNI and NDK are only used by unpatriotic second class citizens with divided loyalties, so they don't deserve to be well supported or maintained.
https://www.zdnet.com/article/100-pure-java-initiative-wins-...
>"Keep Java pure" is the message behind Sun Microsystems' 100% Pure Java initiative which has already won support from 100 developers but will lock out programs such as Visual J++. The move is an attempt on behalf of the Californian firm to maintain integrity of Java code and build awareness.
https://www.cnet.com/news/100-pure-java-watered-down/
>Viewers of cable news network MSNBC may recently have seen a commercial for Sun Microsystems (SUNW) in which a man tells a priest that he's been thinking "pure" thoughts. When the beatific man exits the confessional, he passes a queue of anxious programmers--one wearing a Visual Basic shirt--ready to admit their sins.
>The commercial, which touts Sun's "100 percent pure Java" campaign, is not your usual television ad. But Sun has in many ways shown an almost religious determination to spread the gospel of Java to the far reaches of the globe, even sponsoring a worldwide educational tour for programmers with the support of Netscape Communications, IBM, and Novell.
Much more likely is using a library like NumPy where someone else has done that C performance work for you.
Plus in 2019, it's much cheaper to design for horizontal scale and spin up a few more instances.