Hello,
There was a very interesting talk at Pycon about using Cython to speed up
hotspots in Python programs:

https://www.youtube.com/watch?v=_1MSX7V28Po

It got me wondering about possibly using Cython in selected places within
Django. I realize since Django was first released the distribution
situation was a bit more wild-west, resulting in part to Django not relying
on any third party dependencies. But that situation is rapidly changing
(see
https://github.com/django/deps/blob/master/draft/0007-dependency-policy.rst#background-and-motivation)
and with these changes could it also be a time to investigate Cython usage
for select parts of Django?

Several popular projects use Cython 'speedup' modules with pure-python
fallbacks with great success, for example aiohttp (
https://github.com/aio-libs/aiohttp/blob/master/setup.py#L20). I did some
quick and dirty profiling of the 'django.utils.html.escape' function and
found that by simply including Cython as part of the build, and with no
syntax changes, the function executes twice as fast.

There are lots of considerations to take into account (like ensuring the
Cython functions are in sync with the fallback ones), but it seems that it
could make a big difference with small, self contained functions (like
html.escape or html.escapejs) that are executed frequently as part of a
request. Other functions that might be worth looking at include
core.http.mutliparser.parse_header or utils.baseconv.BaseConverter.convert.

My question is: this this something that's worth exploring, or is it
outside of the realms of possibility?

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAFNZOJOsAdL422Ntj4cUkYF1bjqUBdMAXp33xZ%3DapSwqXMasvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
  • Cytho... Tom Forbes
    • ... 'Carl Meyer' via Django developers (Contributions to Django itself)
    • ... Russell Keith-Magee
      • ... Tom Forbes
        • ... Curtis Maloney
          • ... Adam Johnson
        • ... Florian Apolloner
    • ... ijazz jazz

Reply via email to