Show HN: Python framework is faster than Golang Fiber

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern API for authentication & user identity.
  • LearnThisRepo.com - Learn 300+ open source libraries for free using AI.
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • socketify.py

    Bringing Http/Https and WebSockets High Performance servers for PyPy3 and Python3

    I'm reading some arguments and counter-arguments in this thread, and in my opinion it kinda boils down to what point of view you're having.

    If you look at it as a framework that minimises the networking overhead, then fine, it's an interesting piece of software.

    If on the other hand you look at it like a "fast" web framework then things start to change and the discussion gets a bit more complicated.

    So for example, you look at the source code of the applications being benchmarked (example: https://github.com/cirospaciari/socketify.py/blob/main/bench...) and you immediately see it's simply returning the string "hello world"). Which means that it's almost 100% of the time running in the fast path / best case.

    My guess is that as soon as you start doing any kind of computation in the request handler in normal non-super-optimized python (trival example: validating some headers and/or checking some signatures as you would do with jwt tokens for example) then the python-vs-golang gap will start to go back to favour golang.

    And then again, it boils down to what you're doing: anything io-intensive might benefit from the unetworking/uwebsocket beneath, anything cpu-intensive will benefit from the golang compiler producing native executable code.

    Nice work anyways.

  • FrameworkBenchmarks

    Source for the TechEmpower Framework Benchmarks project

    Actually the benchmark is on https://github.com/TechEmpower/FrameworkBenchmarks with is basically this with more headers, but you are right, is not enought, i used TechEmPower because is very popular. I have some issues open to create an better JWT token support, database and much more, i will post these in the future!

  • WorkOS

    The modern API for authentication & user identity. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • typedload

    Python library to load dynamically typed data into statically typed data structures

    I read all the perftests in the repo. I think they nearly all parse a structure that contains a repetition of the same or similar thing a couple hundred thousand times times and the timing function returns the min and max of 5 attempts. I just picked one example for posting.

    Not a Python expert, but could the Pydantic tests be possibly not realistic and/or misleading because they are using kwargs in __init__ [1] to parse the object instead of calling the parse_obj class method [2]? According to some PEPs [3], isn't Python creating a new dictionary for that parameter which would be included in the timing? That would be unfortunate if that accounted for the difference.

    Something else I think about is if a performance test doesn't produce a side effect that is checked, a smart compiler or runtime could optimize the whole benchmark away. Or too easy for the CPU to do branch prediction, etc. I think I recall that happening to me in Java in the past, but probably not happened here in Python.

    [1] https://github.com/ltworf/typedload/blob/37c72837e0a8fd5f350...

    [2] https://docs.pydantic.dev/usage/models/#helper-functions

    [3] https://peps.python.org/pep-0692/

  • codon

    A high-performance, zero-overhead, extensible Python compiler using LLVM

    Good point! However, you bring in a common misconception I'm fighting with within my company for a long time. Python is not an interpreted language. There is no such thing as an "interpreted language", a language is just a set or rules and keywords. Everything you can fit into Backus–Naur form is already a language even if it doesn't have any implementation nor compiler neither interpreter.

    Just as a piece of evidence, there are interpreted C++ (http://www.artificialworlds.net/wiki/IGCC/IGCC) and AOT Python (https://github.com/exaloop/codon) implementations.

  • pydantic-core

    Core validation logic for pydantic written in rust

    pydandic-core [0] will hopefully solve this issue (written in Rust)

    [0] -- https://github.com/pydantic/pydantic-core

  • Django

    The Web framework for perfectionists with deadlines.

    Django is an WebFramework, Meinheld is an WSGI Server framework.

    https://github.com/django/django

    https://github.com/mopemope/meinheld

    So django meinheld is basically saying that i used Django served by meinheld in that benchmark.

  • meinheld

    Meinheld is a high performance asynchronous WSGI Web Server (based on picoev)

    Django is an WebFramework, Meinheld is an WSGI Server framework.

    https://github.com/django/django

    https://github.com/mopemope/meinheld

    So django meinheld is basically saying that i used Django served by meinheld in that benchmark.

  • LearnThisRepo.com

    Learn 300+ open source libraries for free using AI. LearnThisRepo lets you learn 300+ open source repos including Postgres, Langchain, VS Code, and more by chatting with them using AI!

  • gnet

    🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go./ gnet 是一个高性能、轻量级、非阻塞的事件驱动 Go 网络框架。

    Since we're in the useless benchmark, this Go native library completely wreck any C/C++ lib wrapped by Python: https://github.com/panjf2000/gnet

  • tcpserver

    High performance Golang IPv4 and IPv6 capable TCP server with TLS support, graceful shutdown and TCP FastOpen

  • peps

    Python Enhancement Proposals

    Oh, I have a pretty fresh news for you.

    https://github.com/python/peps/pull/2955

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts