Re: [Django] #17516: Memoize _os.safe_join()

2012-01-08 Thread Django
#17516: Memoize _os.safe_join()
---+--
 Reporter:  Kronuz |Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.3
 Severity:  Normal |   Resolution:  wontfix
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by Alex):

 That was me.

-- 
Ticket URL: 
Django 
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.



Re: [Django] #17516: Memoize _os.safe_join()

2012-01-08 Thread Django
#17516: Memoize _os.safe_join()
---+--
 Reporter:  Kronuz |Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.3
 Severity:  Normal |   Resolution:  wontfix
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by anonymous):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => wontfix
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 I'm wontfixing this.  If safe join is that common in your application you
 can memoize it yourself, I do not think it is sufficiently common in
 django code as to justify the memory increase (remember: memoization is a
 memory/speed tradeoff) for all users.

-- 
Ticket URL: 
Django 
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.



[Django] #17516: Memoize _os.safe_join()

2012-01-08 Thread Django
#17516: Memoize _os.safe_join()
---+
 Reporter:  Kronuz |  Owner:  nobody
 Type:  Uncategorized  | Status:  new
Component:  Uncategorized  |Version:  1.3
 Severity:  Normal |   Keywords:
 Triage Stage:  Unreviewed |  Has patch:  0
Easy pickings:  0  |  UI/UX:  0
---+
 I found out safe_join() was taking a big chunk of time in my project (I
 have many apps and the load_template_source() calls use safe_join).

 Since safe_join() does a lot of repetitive things when it joins paths in
 the same platform, and since the number of joined paths can be sort of
 limited, I made a patch to memoize it.

 Before:

 {{{
 Stats:
  1372899 function calls (1333476 primitive calls) in 1.744 seconds

Ordered by: internal time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 161700.1650.0000.2400.000 posixpath.py:312(normpath)
 152880.1480.0000.1480.000 {posix.getcwdu}
  80850.0730.0000.0730.000 {open}
  10180.0510.0000.0510.000 {method 'recv' of
 '_socket.socket' objects}
 233750.0480.0000.0680.000 posixpath.py:60(join)
1912640.0460.0000.0460.000 {isinstance}
  80850.0420.0000.5660.000 _os.py:28(safe_join)
 800870.0350.0000.0350.000 {method 'startswith' of
 'unicode' objects}
 161700.0350.0000.4820.000 _os.py:18(abspathu)
2468/10.0340.0001.5331.533 base.py:740(render)
 48746/401260.0330.0000.3480.000 {getattr}
2001770.0330.0000.0330.000 {method 'append' of 'list'
 objects}
 8710/78960.0290.0000.0620.000 base.py:373(__setattr__)
 6884/65870.0280.0000.3420.000 base.py:667(_resolve_lookup)
 45540/439230.0280.0000.0870.000
 encoding.py:54(force_unicode)
   1470.0250.0000.6620.005
 app_directories.py:52(load_template_source)
 }}}

 After:

 {{{
 Stats:
  904358 function calls (864935 primitive calls) in 1.123 seconds

Ordered by: internal time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
  10170.0500.0000.0500.000 {method 'recv' of
 '_socket.socket' objects}
  80850.0480.0000.0480.000 {open}
1586300.0400.0000.0400.000 {isinstance}
2468/10.0320.0000.8880.888 base.py:740(render)
 48746/401260.0320.0000.1410.000 {getattr}
 8710/78960.0280.0000.0630.000 base.py:373(__setattr__)
 6884/65870.0270.0000.1350.000 base.py:667(_resolve_lookup)
 300910.0200.0000.0290.000 {hasattr}
 29370/277530.0190.0000.0700.000
 encoding.py:54(force_unicode)
180.0190.0010.0190.001 {method 'execute' of
 'psycopg2._psycopg.cursor' objects}
  66180.0180.0000.0200.000 __init__.py:160(__getattr__)
 }}}

-- 
Ticket URL: 
Django 
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.