Python
Experience: 6 years
For me, Python is a natural choice in cases when the problem in question doesn’t have strict performance requirements or if there is some well-established library in Python ecosystem that can be used for the problem solving.
Web Frameworks
Of all the Python web frameworks I worked with three:
-
FastAPI was used to develop microservices for e-commerce platform that provides integration with Ozon, Wilberries, Tmall, Yandex.Market and Goods marketplaces. FastAPI is really pretty: native typing is used in the name of runtime validation ( pydantic ), wide usage of
asyncio
capabilities, integration withpytest
, and active advocacy of Dependency Injection which allows avoiding many problems with context passing. It’s my primary choice for Python web services at the moment. -
Django was used extensively for development of a monolithic application with various marketplace tools and for development of configuration interfaces for testing equipment. Django is great for making “all-inclusive” standalone applications, but my microservices using it weren’t very “micro”. Of course, REST Framework is our everything!😄 It’s a pity that Django doesn’t seem to have a stable asynchronous ORM , although the author of SQLAlchemy reasonably noted that sometimes asynchronous interaction can be quite painful .
-
Flask was used in the development of a back-end for the diagnostics system (React was used for front-end, see JavaScript ). Because I later discovered FastAPI, I’ve never used Flask again, and I remember only a couple of things about it: for each sneeze you need to install some special plugin ( SQLAlchemy , HTTPAuth …) and that all applications are divided into Blueprints .
ORM and Databases
In Python I usually work with databases using ORM ( SQLAlchemy or Django ), although sometimes SQLAlchemy Core can be enough. Raw SQL queries are certainly indispensable for optimizing performance in the face of growing service loads, however, if the service is really experiencing these kinds of problems, perhaps it’s time to rethink the choice of Python as the service implementation language?..
Before the release of
SQLAlchemy 1.4
, which officially added support for asyncio
via asyncpg
and aiomysql
, it was also interesting to experiment with libraries that benefit from asyncio
, like
Tortoise
,
GINO
or
databases
. They’re not so relevant now though.
GraphQL
This piece of Facebook’s engineering art gained considerable popularity over the last few years, so I couldn’t stand aside, especially in the light of solving the perennial problem of back-end/front-end interfaces coordination.
Despite the obvious dominance of JavaScript in this area, there are some good GraphQL-libraries in the Python ecosystem as well:
-
Graphene is one of the first libraries and the most popular in ecosystem at the moment. After using it for a while, I came to the conclusion that an additional layer between GraphQL schemas and a DB layer is not a very good idea. Starlette previously had built-in support for Graphene, but it’s been removed .
-
Ariadne is younger than Graphene, but it fixes its main drawback: schemas aren’t written using special Python classes but are parsed directly from files with GraphQL schemas. I used Ariadne with Starlette , it worked fine (except for
DataLoader
, which is discussed below). -
Strawberry is a very recent addition based on Python’s answer to structs . Couple of months ago there were stubs all over its documentation, so I didn’t use it much. It will be very interesting to try when this 🍓 ripens.
The biggest problem with all these libraries was the lack of some mechanism that caches DB queries and automatically compiles them into a batch query. ( DataLoader ). To some extent, this idea was implemented for both Ariadne and Graphene (perhaps, Raspberry can handle it finally?), but conjugation of these solutions with database queries is still not a very pleasant experience, especially in the face of constantly changing GraphQL schemas.
Code Quality
I try to use typing all the time and to control types with static analyzers like mypy and Pyright (by the way, the latter is very good as LSP server - more snappier than palantir’s one for sure).
Of the linters, I mostly use flake8 . Recently I used pylint as well but I dropped it at some point. Black and yapf didn’t find much support in my past teams, so I’m not used to using them.
And, since, in my opinion, tests are a mandatory element of CI, pytest is my man!😄 (by the way, qutebrowser by the same guy is 🔥 as well)
(Data) Science & Machine Learning
Python ecosystem has a lot of excellent scientific libraries which had come in handy while I did some research works in graduate school. I often used
pandas
to analyze devices that I developed (later, it also turned out that pandas
does quite well with Keras, which I used to experiment with UAV control systems).
Since I had a traditional control systems engineering training at university, naturally, MATLAB was my first language for control system development. However, at some point I noticed how well everything works out with pandas
and decided to switch to Python for control systems as well. The
python-control
library covered my needs quite well.
Later, while working on UAV control systems, I had the idea to make an adaptive controller based on Reinforcement Learning, so I started to fiddle with Keras . Unfortunately, it turned out that neural networks isn’t very suitable technology for such a task (for more details, see the control systems ).
Other ML work was done while working on an e-commerce platform. This time it was decided to use Pytorch because, despite its enourmous size, torchvision fit well to the task at hand, and the presence of the necessary pre-trained models was clearly a plus. The result was positive, but project was frozen at some point.
Illustration
I didn’t expect a kind of spanish inquisition!
It took me longer to create this illustration than everything else! (not taken together though) Initially, I wanted to create some kind of a collage in the spirit of Terry Gilliam’s applicative animations with references to the incomparable Holy Grail and The Life of Brian and a bunch of libraries that I happened to use:
But I didn’t like the result. More precisely, I didn’t like how it looked in the general context. So, in the end, I decided that I need something completely different !😅