r/Python • • Nov 13 '20

News Python swallows Java to become second-most popular programming language

https://www.theregister.com/2020/11/12/python_swallows_java_to_become/
2.3k Upvotes

205 comments sorted by

View all comments

Show parent comments

169

u/harylmu Nov 13 '20 edited Nov 13 '20

I think this quote is really not accurate because speed isn't the most important (well, usually), but a good concurrency story can save big dollars. I rewrote one of our Python app in .NET Core 5 and I wasn't able to kill it with load testing (2000 req, 200 concurrency), while the Python 3.8 app with FastAPI (literally) hanged around 25 requests per second. And to be clear: I made sure that all IO operations are async in the Python version (database queries, Consul queries, SNS publish, S3 upload - even though aioboto3 isn't too stable yet). This alone means that we're able to save thousands (millions on long term?) of dollars by running less instances.

Other than that, the speed difference between Python and typed languages is really NOT nanoseconds. I don't know what to say, test it yourself.

45

u/aes110 Nov 13 '20

I dont know anything about what your app did, but 25req/s hanged? are you sure there wasn't any bug there?

I rewrote my previous company's system from sync (flask) to async (sanic) and saw huge improvements, we saved ~7K dollars monthly on instances because of this.

In my current company, I'm also using sanic and my server easily handles 400 reqs per second, didnt really tried pushing more to it.

In anycase typed/compiled languages sure are much faster, but I think asyncio cand easily handle most stuff

0

u/[deleted] Nov 13 '20

[deleted]

13

u/aes110 Nov 13 '20

I prefer sanic, for the current project that I'm working on I had time to decide so I investigated both of them, for me FastAPI has good pros:

  1. Seamless integration with Pydantic and type hints

  2. Amazing documentation which is extremely beginner friendly.

  3. Seamless support for sync methods, however while this is good for beginners I dont think you should use it, when mixing sync and async code it's important to know what you are doing.

However I feel like FastAPI takes too many decisions for you so its much less flexible.

I wrote my own small sanic integration with pydantic that I carry around from my previous company as well.

Tbh I cant think of something specific to highlight as sanic's pros, it just works really well

Although the two are not different to such extremes, but in a sense you could say that sanic and FastAPI are like Flask and Django