#11739: ContentFile() does not support unicode data
--------------------------------------+------------------------------------
     Reporter:  adamnelson            |                    Owner:  nobody
         Type:  Bug                   |                   Status:  reopened
    Component:  File uploads/storage  |                  Version:  1.1
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by codysoyland):

 I did some really basic benchmarks that show the first patch, which
 removes the cStringIO module completely, is much faster on unicode data,
 but slower on binary data than the second patch, which wraps the cStringIO
 module. I don't know how conclusive these tests are though, because they
 are with small datasets.

 Test script (unicode):

 {{{
     from django.core.files.base import ContentFile
     import timeit
     print timeit.timeit(lambda: ContentFile(u'test').read())
 }}}

 Test script (bytes):

 {{{
     from django.core.files.base import ContentFile
     import timeit
     print timeit.timeit(lambda: ContentFile('test').read())
 }}}

 I ran each script 3 times on each patch. timeit runs the function
 1,000,000 times and returns the number of seconds elapsed.

 11739_with_test.diff (No cStringIO)

 {{{
 Unicode results:
 7.600399017333984
 7.397403955459595
 7.361830949783325

 Bytes results:
 8.416419982910156
 7.377918004989624
 7.391348123550415
 }}}


 11739-3.diff (Wrapped cStringIO)

 {{{
 Unicode results:
 14.868388175964355
 14.914705991744995
 14.742434024810791

 Bytes results:
 5.290870904922485
 4.712155818939209
 5.349420070648193
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/11739#comment:13>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to