Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(16)

Delta Between Two Patch Sets: Objects/rangeobject.c

Issue 602: range: lean and mean (Closed) SVN Base: http://svn.python.org/view/*checkout*/python/branches/py3k/
Left Patch Set: address more concerns Created 5 months, 1 week ago , Downloaded from: http://bugs.python.org/file10183/range_lean_and_mean5.patch
Right Patch Set: __len__ is back! Created 5 months, 2 weeks ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* Range object implementation */ 1 /* Range object implementation */
2 2
3 #include "Python.h" 3 #include "Python.h"
4 #include "structmember.h" 4 #include "structmember.h"
5 5
6 /* Support objects whose length is > PY_SSIZE_T_MAX. 6 /* Support objects whose length is > PY_SSIZE_T_MAX.
7 7
8 This could be sped up for small PyLongs if they fit in an Py_ssize_t. 8 This could be sped up for small PyLongs if they fit in an Py_ssize_t.
9 This only matters on Win64. Though we could use PY_LONG_LONG which 9 This only matters on Win64. Though we could use PY_LONG_LONG which
10 would presumably help perf. 10 would presumably help perf.
(...skipping 104 matching lines...) Show 10 above Show 10 below
115 static void 115 static void
116 range_dealloc(rangeobject *r) 116 range_dealloc(rangeobject *r)
117 { 117 {
118 Py_DECREF(r->start); 118 Py_DECREF(r->start);
119 Py_DECREF(r->stop); 119 Py_DECREF(r->stop);
120 Py_DECREF(r->step); 120 Py_DECREF(r->step);
121 Py_DECREF(r->length); 121 Py_DECREF(r->length);
122 PyObject_Del(r); 122 PyObject_Del(r);
123 } 123 }
124 124
125 /*Return number of items in range (lo, hi, step), when arguments are
126 * PyLong objects. step > 0 required. Return a PyLong with the length.
127 * Return NULL when there is an error.*/
128 static PyObject * 125 static PyObject *
129 range_compute_length(PyObject *start, PyObject *stop, PyObject *step) 126 range_compute_length(PyObject *start, PyObject *stop, PyObject *step)
130 { 127 {
131 /* ------------------------------------------------------------- 128 /* -------------------------------------------------------------
132 Algorithm is equal to that of get_len_of_range(), but it operates 129 Algorithm is equal to that of get_len_of_range(), but it operates
133 on PyObjects (which are assumed to be PyLong or PyInt objects). 130 on PyObjects (which are assumed to be PyLong or PyInt objects).
134 ---------------------------------------------------------------*/ 131 ---------------------------------------------------------------*/
135 int cmp_result, cmp_call; 132 int cmp_result, cmp_call;
136 PyObject *lo, *hi; 133 PyObject *lo, *hi;
137 PyObject *diff = NULL; 134 PyObject *diff = NULL;
(...skipping 520 matching lines...) Show 10 above Show 10 below
658 return NULL; 655 return NULL;
659 } 656 }
660 657
661 return (PyObject *)it; 658 return (PyObject *)it;
662 659
663 create_failure: 660 create_failure:
664 Py_XDECREF(len); 661 Py_XDECREF(len);
665 PyObject_Del(it); 662 PyObject_Del(it);
666 return NULL; 663 return NULL;
667 } 664 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r338