2018-05-29 : 10:00
2018-05-27 : 23:17
2018-04-23 : 18:03
2018-04-06 : 14:55
2018-03-24 : 14:41
2018-07-19 : 05:13
If old Python networking and web libraries aren't fast enough for you, these new additions break speed limits and unleash new possibilities...
Faster, simpler, more “Pythonic” – those are the rallying cries for each new web framework in the Python ecosystem. There’s nothing wrong with tried-and-true solutions, but the big leap from Python 2 to Python 3 has brought all sorts of potential improvements, including a powerful asynchronous event framework that is perfect for network libraries.
Here are five recently minted web and network frameworks for Python that ramp up the speed, take advantage of new breakthroughs, and provide fresh spins on old ideas.
The concept for Sanic is simple: Provide a web framework with a syntax based on the widely used Flask, but build it on top of the wicked-fast asynchronous event handlers available in Python 3.5 and up. The result? A framework that can serve 33,000-plus requests per second to Flask’s 4,988, and at almost one-tenth of the latency. (Benchmarks provided by the authors.) Routing and middleware are both included, too. It’s not clear how readily Flask can be swapped out for Sanic in an existing app, but it’s worth a try if you want to see how much of an improvement you can have.
If you’re looking to build web services and want a quick way to get started with known-good components, Eve has been designed with all that in mind. It uses Flask as its web framework, and it can plug into MongoDB, SQL-Alchemy, Elasticsearch, or Neo4js back ends for data access. The developers stress simplicity of deployment: “All you need to bring your API online is a database, a configuration file (defaults to settings.py), and a launch script.”
Morepath bills itself as a “super-powered” Python web framework with a minimal setup footprint. It’s designed to get many typical use cases up and running quickly, such as turning common Python data structures into RESTful web services. One unique feature: It automatically turn paths defined in Morepath into links to create applications with elegant and clean URLs.
If you’re looking for a network library that’s designed to be async and secure by default, ButterflyNet was built with those goals in mind. It’s Python 3.5 and up only, since it uses the asyncio library for its magic, but setting up servers and passing it certificates and keys can be done in a dozen or so lines of code; a simple chatroom example is only 75 lines.
With a pitch like “blazing fast Python networking,” this one’s hard to ignore. Uvloopis a drop-in replacement for the asyncio event loop, so it can either be used as the basis for a new asyncio-based application or to replace asyncio in an existing one. It also gets points for working with the Python accelerator Cython, so the most crucial code is actually written in C. Its creators claim it’s “at least 2x faster than Nodejs, gevent, as well as any other Python asynchronous framework,” but test it for yourself and see.