#36705: Repeated string concatenation is slow on some python implementations, in
particular PyPy
-------------------------------------+-------------------------------------
     Reporter:  Jacob Walls          |                     Type:
                                     |  Cleanup/optimization
       Status:  new                  |                Component:  Utilities
      Version:  dev                  |                 Severity:  Normal
     Keywords:  PyPy                 |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 There is a [https://pypy.org/posts/2023/01/string-concatenation-
 quadratic.html known limitation] in PyPy that repeated string
 concatenation is slow. The discussion there observes that CPython has an
 optimization, but it's fragile and best not relied on.

 Seokchan Yoon (thanks for the report!) raised this with the security team,
 and we decided any hardening here could be done in public.

 To close this ticket, we should:
 - implement targeted optimizations in django.utils.numberformat.format()
 to avoid repeated string concatenation
 - audit for other similar cases
 - Add a disclaimer to our
 [https://docs.djangoproject.com/en/5.2/topics/performance/#id1
 documentation] around PyPy, for example, wording like:

 > That said, a lot of a web framework's work is done by concatenating
 strings, and PyPy has an issue with that (see
 https://pypy.org/posts/2023/01/string-concatenation-quadratic.html). This
 may cause performance issues, depending on your use.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36705>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019a4a01ec6a-05a5073b-bef8-47dd-b388-90044fdab0d4-000000%40eu-central-1.amazonses.com.

Reply via email to