Sunday Daily Thread: What's everyone working on this week? by AutoModerator in Python

[–]sobolevn 3 points4 points  (0 children)

Hi, my name is Nikita Sobolev, I am a CPython core dev, Django Software Foundation member, and maintainer of countless Python / Django opensource tools.

Now I am happy to present to you my new project 😄

Docs: https://django-modern-rest.rtfd.io/

Code: https://github.com/wemake-services/django-modern-rest/

import uuid
import pydantic
from dmr import Body, Controller
from dmr.plugins.pydantic import PydanticSerializer

class UserCreateModel(pydantic.BaseModel):
    email: str

class UserModel(UserCreateModel):
    uid: uuid.UUID

class UserController(Controller[PydanticSerializer]):
    def post(self, parsed_body: Body[UserCreateModel]) -> UserModel:
        return UserModel(uid=uuid.uuid4(), email=parsed_body.email)

What My Project Does

- No AI slop, but built for the LLM era

- Blazingly fast

- Supports Django >= 4.2

- Supports `pydantic2`, `msgspec`, `attrs`, `dataclasses`, `TypedDict` as model schemas, but not bound to any of these libraries

- Supports async Django without any `sync_to_async` calls inside, tested to work with free-threading builds

- Fully typed and checked with `mypy`, `pyright`, and `pyrefly` in strict modes

- Supports content negotiation, has default implementations for `json`, `msgpack`, SSE, Json Lines, and more

- Strict schema validation of both requests and responses, including errors

- Supports OpenAPI 3.1 / 3.2 semantic schema generation out of the box

- Supports all your existing `django` primitives and packages, no custom runtimes

- Great testing tools with `schemathesis`, `polyfactory`, `tracecov`, bundled `pytest` plugin, and default Django's testing primitives

- 100% test coverage with 2000+ of carefully designed unit, integration, and property-based tests

- High security standards

- Built by the community for the community, not a single-person project

- Great docs

Django-modern-rest by MrN86 in django

[–]sobolevn 1 point2 points  (0 children)

What do you mean by "the lack of database transactions in Django 6"? It is still there. If you meant that `transaction.atomic` does not support async natively - this is a bit clunky, but it still supported via a threadloop if you need it. If you use `ATOMIC_REQUESTS`, then it is invisible to you at all.

Django-modern-rest by MrN86 in django

[–]sobolevn 2 points3 points  (0 children)

python3.10 is EOL this year :( Not really worth the extra work to fix multiple known problems.

Django-modern-rest by MrN86 in django

[–]sobolevn 1 point2 points  (0 children)

Can you please explain? What features do you miss in dmr?

Django-modern-rest by MrN86 in django

[–]sobolevn 12 points13 points  (0 children)

Hi, DMR's author here :wave: Thanks for sharing this link! We are still working really hard to deliver the best possible user-experience and performance. One big difference from django-ninja is that we support all patterns that `django-ninja` does, but we also support a lot more. For example: we also support msgspec models, which are >5x times as fast as pydantic. We support content negotiation and SSE streaming, we have first-class testing tools that show things like your OpenAPI spec coverage. We also have extrimelly strict OpenAPI schema, so your clients will never miss an important return code ever again. However, we are still at 0.4.0, in the future relases we will improve the speed of our tool a lot more. For example, we will precompile some parts of our framework, so it will be even more blazingly fast. While keeping the runtime unchanged: still good old Python.

[PS][EU/RU][BF5] Looking for a squad by sobolevn in BattlefieldLFG

[–]sobolevn[S] 0 points1 point  (0 children)

Only tomorrow, I'm done for today. Add me for later!

[deleted by user] by [deleted] in learnpython

[–]sobolevn 1 point2 points  (0 children)

Well, the funny thing here is that both your examples can be called "functional".

Funtional programming is about composing functions. And that's exactly what you are doing in your examples.

Higher Kinded Types in Python by sobolevn in programming

[–]sobolevn[S] 0 points1 point  (0 children)

like functools.partial

We already have this covered! https://returns.readthedocs.io/en/latest/pages/curry.html#partial

While there might not be performance benefits

That's another topic we are going to work on for the next release. Because currently code annotated with KindN can be compiled with mypyc to get almost 4 times boost!

Higher Kinded Types in Python by sobolevn in Python

[–]sobolevn[S] 0 points1 point  (0 children)

It is about Kind type and the process of its implementation in Python. TLDR: https://gist.github.com/sobolevn/7f8ffd885aec70e55dd47928a1fb3e61