Sync and Async versions of the same function: guidelines for contributors

2023-08-05 Thread Olivier Tabone
Hi all, While working on async related tickets (eg #34717, and more recently #34757) I noticed code duplication between sync and async version of same functions: some examples: (no personal offense ❤️) - acheck_password / check_password in base_user.py

Re: Sync and Async versions of the same function: guidelines for contributors

2023-08-05 Thread Jon Janzen
Hey there, > Not that much with a 50 lines function. that could easily become a maintenance burden. > what do you think about code duplication of async function ? (please point me to existing threads if the discussion already occurred) I flagged this problem in https://forum.djangoproject.com

Re: Sync and Async versions of the same function: guidelines for contributors

2023-08-07 Thread Lufafa Joshua
Hi there, Just a quick assumption, code duplication could be the reason why the follow parameter and the _handle_redirects method was not implemented on the AsyncClient as per the ticket #34757, if my assumption is wrong, no big deal. Kind regards. On Sat, Aug 5, 2023 at 8:45 PM Jon Janzen wro

Re: Sync and Async versions of the same function: guidelines for contributors

2023-08-07 Thread Olivier Tabone
Le lundi 7 août 2023 à 14:43:26 UTC+2, Lufafa Joshua a écrit : Hi there, Just a quick assumption, code duplication could be the reason why the follow parameter and the _handle_redirects method was not implemented on the AsyncClient as per the ticket #34757, if my assumption is wrong, no big

Re: Sync and Async versions of the same function: guidelines for contributors

2023-08-07 Thread Olivier Tabone
Hi Jon, Thank you for your input. Le samedi 5 août 2023 à 19:43:57 UTC+2, Jon Janzen a écrit : There are a few key things missing from core django before that's possible. Some of which are laid out in that forum thread I linked above, others are listed directly in the DEP like the ORM being f

Re: Sync and Async versions of the same function: guidelines for contributors

2023-08-07 Thread Mariusz Felisiak
I also understand that the heavy lifting in async_to_sync and sync_to_async wrapper has been implemented and the hard work like thread affinity is managed by these wrapper. Switching between sync and async context is not fre

Re: Sync and Async versions of the same function: guidelines for contributors

2023-08-16 Thread 'Adam Johnson' via Django developers (Contributions to Django itself)
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 wa