I think some duplication will always be required, unfortunately. Bridging
the two paradigms is necessarily costly as it involve communicating between
threads. IMO duplication is worth it to avoid performance regressions for
sync code, and to make async code worth using.

I am doubtful there is a way for Django to have a purely async core with a
sync wrapper.

On Mon, 7 Aug 2023 at 20:01, Mariusz Felisiak <felisiak.mari...@gmail.com>
wrote:

>
> I also understand that the heavy lifting in async_to_sync and
> sync_to_async wrapper has been implemented
> <https://docs.djangoproject.com/en/4.2/topics/async/#async-to-sync> and
> the hard work like thread affinity is managed by these wrapper.
>
>
> Switching between sync and async context is not free, it can cause a
> significant performance degradation. As far as I'm aware, using
> async_to_sync/sync_to_async wrappers is a temporary solution to provide an
> async interface when we don't have all async elements ready.
>
> Best,
> Mariusz
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/3fc1d122-94e5-4e58-a824-8ad1235399acn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/3fc1d122-94e5-4e58-a824-8ad1235399acn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM1JuFqerCH9NBYegmp6JpXiK1kxua8jtR%3DU_qJL6QECOw%40mail.gmail.com.
  • Syn... Olivier Tabone
    • ... Jon Janzen
      • ... Lufafa Joshua
        • ... Olivier Tabone
      • ... Olivier Tabone
        • ... Mariusz Felisiak
          • ... 'Adam Johnson' via Django developers (Contributions to Django itself)

Reply via email to