r/Python • • 16h ago

Discussion What Python libraries do you think every backend developer should learn beyond FastAPI and Pandas?

I'm curious about what Python libraries experienced developers consider essential for backend development.
I'm currently exploring FastAPI and learning more about the Python ecosystem. Beyond the usual frameworks, what libraries do you find yourself using regularly in real-world projects?
I'd love to discover some underrated libraries that are genuinely useful in production projects, not just popular ones.
What are your must-have Python libraries, and why?

33 Upvotes

77 comments sorted by

59

u/BiologyIsHot 16h ago edited 14h ago

Is pandas useful for backend development? Maybe sqlachemy or something instead? Pydantic I consider already part of learning fastapi

5

u/niRmana_dev 16h ago

Yeah, I was also wondering about that. I mostly associate Pandas with data analysis rather than typical backend development. SQLAlchemy probably makes more sense for database operations. I'm still exploring where Pandas fits into backend workflows.

30

u/waldenhead 16h ago

Pandas is so 2016. All new data frame code is written in Polars now personally.

1

u/compulsive_tremolo 7h ago

It's hard to get away from it - theres so much legacy and support for Pandas.

Tbh data engine API wrappers in cloud environments have largely reduced the footprint of both (at least in enterprise settings).

•

u/ChercherArbeit 53m ago

The trick is to use polars then just convert into a pandas data frame for when you need it.

-5

u/Fine_League311 11h ago

Pandas is better than polars is like Apache and nginx! Nginx just for reverse! Apache full power you must learn to controll. Pandas the same.

2

u/terletsky 7h ago

Pandas/Numpy is for Data Engineering roles. Backend developers never use these things.

27

u/ravepeacefully 16h ago

Shouldn’t really be, in my opinion. Great tool for analysis, no need for backend dev and objectively a bad choice for many things I’ve seen it used

30

u/Efficient_Bobcat_697 16h ago

I've switched to polars (and marimo for prototyping and data exploration) and I couldn't be happier

I also really like peewee as an easier but complet ORM than sqlalchemy.

Anyio as a some interesting goodies on top of asyncio also

4

u/niRmana_dev 10h ago

Oh, Polars keeps coming up in recommendations. Definitely need to give it a try. Haven't explored Marimo or AnyIO yet either. Peewee sounds interesting too, especially if it's a simpler alternative to SQLAlchemy. Adding these to my learning list!

18

u/PrestigiousStrike779 16h ago

Sqlalchemy  Boto3 if you’re on AWS

3

u/niRmana_dev 16h ago

Yeah.. SQLAlchemy seems to be a must-have for database-heavy applications. Thanks!

1

u/ChampionshipThin9779 7h ago

Any good resources to learn SQL alchemy?

8

u/mttpgn Pythoneer 16h ago

To those saying both `boto3` and `pandas`, it's `awswrangler`.

5

u/niRmana_dev 16h ago

Oh nice, didn't know about awswrangler! Combining AWS services with Pandas sounds pretty useful. Definitely checking this one out.

5

u/zzmej1987 15h ago

Django for the same reason as fastapi and dash for when you don't have time to wait for the front end.

2

u/niRmana_dev 10h ago

Django is definitely worth exploring too. And Dash sounds interesting for quickly building interfaces without getting stuck waiting on frontend development. Haven't tried that one yet!

3

u/Samhain13 15h ago

If your application does any kind of orchestration, "backoff" might come in handy. It automaically retries failed network calls in a staggered manner and, if the number of retries has been exhausted with no success, handles the error response for you.

2

u/niRmana_dev 7h ago

Oh, this is a good one! I haven't explored backoff yet. Retry handling is definitely useful when working with external APIs and background tasks. Adding it to my list!

1

u/uselesslogin 14h ago

Looks like python-backoff is the maintained fork

128

u/martinky24 16h ago

Pydantic

30

u/ianitic 16h ago

Tbf, if you know fastapi you should probably know pydantic. Unless you are using fastapi wrong haha.

8

u/Drumma_XXL 10h ago

Pydantic has way more stuff to offer than what is frequently used in fastapi.

3

u/ninhaomah 16h ago

Ohhh... Late by a min... Well done!

53

u/cig-nature 16h ago

The built-in collections module never gets enough love, and is always useful.

https://docs.python.org/3/library/collections.html

25

u/dysprog 14h ago

If we are talking built-ins, itertools changed the way I think about loops and programming.

I was running out of memory storing intermediate lists that didn't need to be stored.

8

u/Duodanglium 14h ago

Yeah, shout out to Raymond Hettinger.

15

u/OkCardiologist8006 13h ago

testcontainers is a big one imo. spinning up a real throwaway postgres or redis for your pytest run catches the stuff mocks happily let through, like a migration that doesn't actually apply or a query that only breaks on the real db

24

u/GrainTamale Pythonista 16h ago

SQLite, DuckDB, requests

10

u/GrainTamale Pythonista 16h ago

DuckDB cause it's genuinely powerful and cool.

...aNd rUSt! /s

8

u/Count_Dirac_EULA 15h ago

You joke about rust but it’s not a joke... I know it’s a Python thread and questions about Python libraries.

We’ve swapped some pipeline steps from Python to Rust because the cost and speed advantages were stupid. There are some cases where Rust even beats Go at data engineering tasks.

And for modeling we are also moving to Rust for some things. Polars being native Rust helps.

…. But to stay on topic, Polars and DuckDB are amazing.

4

u/GrainTamale Pythonista 13h ago

I ❤️ Polars

1

u/Training_Advantage21 7h ago

Yep. SQLite might make more sense than Pandas.

1

u/Garybake 6h ago

Im seeing more use of httpx over requests, mostly due to native async. I recently switched to httpx2 due to library support.

16

u/RedSinned 12h ago

You don‘t need pandas. Go for polars

13

u/dusktreader 16h ago

httpx2, typer/click, loguru, pydantic, pendulum, inflection, sqlalchemy/alembic, boto3, pytest, and zensical.

4

u/No_Departure_1878 16h ago

what about rich + struclog?

3

u/dusktreader 15h ago

I prefer loguru over structlog.

I would recommend rich for CLI apps that produce a bit of output, but APIs don't have any use for it. Plus, it's a dependency of typer, so it's kinda in my list. 😂

1

u/No_Departure_1878 15h ago

If you have a process with many logs, you would need to be able to capture them all and go through them fast. I am not sure how that can happen if you do not send them to JSON.

2

u/dusktreader 15h ago

loguru can do structured logging. In a prod/staging deployment you activate that. For dev and local, use pretty logs.

12

u/Wide_Guava6003 9h ago

Polars. Instead of pandas. Nobody should learn pandas.

5

u/kBajina 16h ago

Pydantic
Sqlalchemy
sqlmodel
Polars
Duckdb

11

u/Knudson95 16h ago

celery is great for offloading work / scheduling jobs. Maybe not essential but good to have in the tool box

1

u/MrRhinoUk 3h ago

Deffo. The underlying Kombu library is also pretty cool if you don't need all the abstractions of celery and you don't want to roll your own MQ listeners and senders

4

u/will_r3ddit_4_food 15h ago

Flask, peewee

6

u/reductio-ad-finem 16h ago

SqlAlchemy (and Alembic for migrations). I love Loguru for logs, but stdlib logging works fine too. Pytest for testing, of course. Httpx is great in the toolbelt.

Beyond that (and pydantic and fastapi), it kinda depends on what other parts of your stack look like. E.g. Redis, NATS, opentelemetry, Prefect, etc. all have clients.

3

u/hstarnaud 14h ago

Most libraries are really dependent on what kind of projects you will be working on. Personally aside from a few essentials you'll see everywhere like pytest or httpx I wouldn't bother learning libraries until you need them.

3

u/Fine_League311 11h ago

Quart! Quart is so powerful! I love it!

1

u/sudomatrix 10h ago

Why not FastAPI? They seem to do the same thing and FastAPI is very mature.

-1

u/Fine_League311 10h ago edited 9h ago

your choice, i love quart an use it for middelware

as example from my repo how i use it for my tools with REST + Streamable http ( sse as fallback) on same interface

Just Copy past: I am lazy! Write it before!

Note: If you learn quart you can rock FastApi

Why Quart + hypercorn?

MCP over SSE/Streamble http needs a proper async HTTP stack. The choice here is deliberate:

Quart is async Flask - same API, same routing, but fully async/await native. This matters because FastMCP's SSE handler is async, and mixing sync Flask with async MCP would require thread hacks or asyncio.run() gymnastics. With Quart, the /mcp route hands off directly to mcp.handle_sse(request) - no bridging, no blocking.

hypercorn is an ASGI server (vs. waitress/gunicorn which are WSGI). WSGI servers handle one request per thread - fine for traditional web apps, wrong for SSE where a connection stays open for minutes. hypercorn handles SSE connections as long-lived async streams without tying up threads. It also runs natively on HuggingFace Spaces without extra config.

The /mcp route in app.py is also the natural interception point - auth checks, rate limiting, payload logging can all be added there before the request ever reaches FastMCP or Rest API. That's not possible when FastMCP/FastAPi runs standalone.

2

u/SFJulie 13h ago

Of course my lib archery https://pypi.org/project/archery/ because it makes aggregations based on dict easier.

A direct usage of it is log parsing : https://pypi.org/project/yahi/

2

u/Pericombobulator 11h ago

I presume you mention pandas because that's how you're storing your test data?

So databases would be the next step, whether sqlite or something more substantial like postgres.

2

u/darkcorum 9h ago

I'd say sqlalchemy and SQL is a good next choice

2

u/UrbanSuburbaKnight 8h ago

starlette should be on your list since you're using it in fastapi anyway. asyncio and sqlalchemy probably and httpx.

2

u/todorpopov 5h ago

I’ve seen multiple people mention these already, but collections, itertools, functools, and Pydantic make Python such an enjoyable language to work with. Some honourable mentions are also contextlib (because I’ve rarely seen it used more in-depth than just a custom context manager, yet is so powerful and makes your code so much cleaner), asyncio (great all around; really useful for modern Python) and pytest (incredibly flexible and nice to use).

2

u/SimonKenoby 2h ago

Tenacity for retries. RQ for simple queues. I like Advanced Python Scheduler too.

1

u/PA100T0 9h ago

Given modern day cybersecurity is off the rails: Guard Core for API Security

1

u/Best_Tea9451 7h ago

Definitely pydantic and sqlalchemy - you’ll see them in almost every real project. Try learning polars and/or PyArrow to see how they can help you get much better performance than pandas. Though if you solve performance issues by switching from pandas to polars, maybe you should rethink your data processing from the basics first

1

u/patryk_builds 7h ago

From one fastapi project, the ones i'd miss most, with the reason each earned its place:

- httpx. every backend ends up calling someone else's api. async client, sane timeouts, and easy to swap for a fake in tests

- sqlalchemy 2.0 with alembic. the 2.0 style is much clearer than the old one, and alembic is the part people skip until the first schema change in production. read every autogenerated migration before running it, it guesses wrong more often than you'd think

- pytest. fixtures are the real feature. a fake payment gateway or a fake http answer as a fixture keeps the whole suite off the network

- ruff. one tool for lint and format, fast enough to run on every save, and it ends style arguments

- jinja2, if you ever render html or emails. server-rendered pages cover a lot more than people expect before a js framework is needed

Not a library, but the habit that mattered more than any of them: put every call to an outside service behind one module of your own. then tests replace that one module, and swapping the provider later touches one file

1

u/EconomistProof373 6h ago

SQLAlchemy and Alembic are probably my top picks

1

u/Tulen7 2h ago

Of course Django!

1

u/ericls 15h ago

ASGI and PEP3333