When comparing TurboGears 2 vs FastAPI, the Slant community recommends FastAPI for most people. In the question“What are the best general-purpose Python web frameworks usable in production sites?” FastAPI is ranked 3rd while TurboGears 2 is ranked 11th. The most important reason people chose FastAPI is:
It has a simple but powerful dependency injection system, it can be used to handle authentication, per-user rate limiting, authorization controls (e.g. with roles), etc.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro A powerful and flexible Object Relational Mapper (ORM) with real multi-database support
SQLAlchemy is a powerful ORM which is highly regarded in the Python community. TurboGears' ORM is built with SQLAlchemy, which gives it a great deal of flexibility and power.
Pro Code that is as natural as writing a function
Pro Starts as a microframework and scales up to a fullstack solution
Allows developers to build quick, simple web prototypes or scale up to create complex web applications.
Pro Support for Horizontal data partitioning (aka, sharding)
TurboGears allows for horizontal data partitioning, which allows the division of logical datatabases into smaller elements.
Pro Built in extensibility Pluggable Applications and standard WSGI components
Allows for creating extendable Pluggable Applications which extend the framework itself through endpoints provided by TurboGears.
Pro Validated and compile time checked template engine
The template engine is XHTML based and so is validated for errors when compiled to HTML. You will never serve a broken page again due to a forgotten close tag
Pro Aims for a flexible design
TurboGears2 does not get in your way on how to design your applications, classes etc.
Pro Dependency injection
It has a simple but powerful dependency injection system, it can be used to handle authentication, per-user rate limiting, authorization controls (e.g. with roles), etc.
Pro Standards
It is based on standards: OpenAPI, JSON Schema and OAuth 2.0.
Pro Data validation
It validates the data using the types you declared. Even in deeply nested JSON requests.
Pro High-performance
It's based on Starlette and Pydantic, so, it's one of the fastest Python frameworks.
Pro Editor completion
It is based on Python type declarations, so, editors and tools can give great support. Including type checks and autocompletion everywhere.
Pro One of the fastest growing communities
Pro Fast is really fast (!)
It's easy to develop API based applications in Python on deadlines for Android and IOS Development.
Pro Automatic docs
It generates interactive API documentation automatically from your code.
Pro Database independent
It's independent of database or ORM, but compatible with all of them. Including relational databases and NoSQL.
Pro Async IO / optional
It's based on Async IO, which gives it high concurrency. But you can use non-async libraries and it runs them appropriately.
Pro World class documentation
It has some of the best documentation of any framework.
Pro WebSockets
Because it's an async framework, it can handle async-native protocols like WebSockets.
Pro OAuth 2.0
It has integrated support for OAuth 2.0. Including declaring required scopes per endpoint. So, you can easily integrate it with external OAuth 2.0 providers or build your own with it.
Pro Background tasks
Included support for background tasks, thanks to being based on Starlette.
Pro Supports GraphQL
Python's graphene library is included as an optional dependency meaning that GraphQL API's are supported out of the box, with no additional tweaking needed.
Cons
Con The great extensibility can feel overwhelming
Sometimes TurboGears' extensibility and feeling of having different options for doing a single thing can feel overwhelming and as if writing everything from scratch.
Con small community
Con Smaller community
Since FastAPI is relatively new, its community is smaller than Django Rest Framework. But it can grow with time.