Code

Opened 7 years ago

Closed 7 years ago

#4462 closed (fixed)

minor ForNode.render reversed optimization

Reported by: (removed) Owned by: adrian
Component: Template system Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

short version, nestled snuggly in django.template.defaulttags.ForNode.render is a homebrewed native reverse implementation; aside from it using range when it should be using xrange, this is fine for <py2.4; for >=py2.4 however, the builtin reversed should be used (fair bit faster among other things).

So... attached is a patch doing just that; for folks using >=2.4, it's a linear 10x boost (mass index lookups kill kittens when in combination with native py vs cpy speeds), so... worth adding.

Attachments (1)

use-builtin-reverse-if-available.patch (1.0 KB) - added by (removed) 7 years ago.

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by (removed)

comment:1 Changed 7 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

Indeed! Looks good.

comment:2 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [5454]) Fixed #4462 -- Use builtin reversed() function when available (in "for" tag).
Thanks, Brian Harring.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.