summaryrefslogtreecommitdiffstats
path: root/Objects/rangeobject.c
Commit message (Collapse)AuthorAgeFilesLines
* Convert iterator __len__() methods to a private API.Raymond Hettinger2005-09-241-8/+10
|
* Disallow keyword arguments for type constructors that don't use them.Georg Brandl2005-08-261-0/+3
| | | | (fixes bug #1119418)
* Remove PyRange_New().Raymond Hettinger2004-12-031-45/+0
|
* Bug 1003935: xrange overflowsTim Peters2004-08-081-1/+16
| | | | | | | | | | | | | | | Added XXX comment about why the undocumented PyRange_New() API function is too broken to be worth the considerable pain of repairing. Changed range_new() to stop using PyRange_New(). This fixes a variety of bogus errors. Nothing in the core uses PyRange_New() now. Documented that xrange() is intended to be simple and fast, and that CPython restricts its arguments, and length of its result sequence, to native C longs. Added some tests that failed before the patch, and repaired a test that relied on a bogus OverflowError getting raised.
* Trimmed trailing whitespace.Tim Peters2004-08-081-5/+5
|
* Add a missing decref.Michael W. Hudson2004-08-021-0/+1
|
* Tidied up the implementations of reversed (including the custom onesRaymond Hettinger2004-03-101-1/+13
| | | | | | | | | | | | | | | | | for xrange and list objects). * list.__reversed__ now checks the length of the sequence object before calling PyList_GET_ITEM() because the mutable could have changed length. * all three implementations are now tranparent with respect to length and maintain the invariant len(it) == len(list(it)) even when the underlying sequence mutates. * __builtin__.reversed() now frees the underlying sequence as soon as the iterator is exhausted. * the code paths were rearranged so that the most common paths do not require a jump.
* Implement and apply PEP 322, reverse iterationRaymond Hettinger2003-11-061-1/+36
|
* Renamed PyObject_GenericGetIter to PyObject_SelfIterRaymond Hettinger2003-03-171-1/+1
| | | | | | to more accurately describe what the function does. Suggested by Thomas Wouters.
* Created PyObject_GenericGetIter().Raymond Hettinger2003-03-171-8/+1
| | | | Factors out the common case of returning self.
* Update comments about the performance of xrange().Raymond Hettinger2002-12-111-2/+2
|
* Restore attribute access so that the following work again:Raymond Hettinger2002-11-071-1/+1
| | | | | dir(xrange(10)) xrange(10).__getitem__(4)
* Untested code for 64-bit platforms. range_length() is declared as intGuido van Rossum2002-09-111-1/+8
| | | | | | | | | | but returns r->len which is a long. This doesn't even cause a warning on 32-bit platforms, but can return bogus values on 64-bit platforms (and should cause a compiler warning). Fix this by inserting a range check when LONG_MAX != INT_MAX, and adding an explicit cast to (int) when the test passes. When r->len is out of range, PySequence_Size() and hence len() will report an error (but an iterator will still work).
* staticforward bites the dust.Jeremy Hylton2002-07-171-2/+2
| | | | | | | | | | | | | | | The staticforward define was needed to support certain broken C compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the static keyword when it was used with a forward declaration of a static initialized structure. Standard C allows the forward declaration with static, and we've decided to stop catering to broken C compilers. (In fact, we expect that the compilers are all fixed eight years later.) I'm leaving staticforward and statichere defined in object.h as static. This is only for backwards compatibility with C extensions that might still use it. XXX I haven't updated the documentation.
* Remove the next() method -- one is supplied automatically byGuido van Rossum2002-07-161-10/+1
| | | | | | PyType_Ready() because the tp_iternext slot is set. Also removed the redundant (and expensive!) call to raise StopIteration from rangeiter_next().
* Patch #568124: Add doc string macros.Martin v. Löwis2002-06-131-2/+2
|
* Pyrangeiter_Type && range_iter should be staticNeal Norwitz2002-06-061-5/+5
|
* Skip Montanaro's patch, SF 559833, exposing xrange type in builtins.Raymond Hettinger2002-06-051-2/+84
| | | | | Also, added more regression tests to cover the new type and test its conformity with range().
* SF 564601 adding rangeiterobject to make xrange() iterate like range().Raymond Hettinger2002-06-051-46/+91
|
* Inverted test for small speedupRaymond Hettinger2002-06-041-5/+4
|
* Patch #551410: Implement tp_getiter.Martin v. Löwis2002-05-081-1/+51
|
* Remove old deprecated features from the xrange object.Fred Drake2002-05-021-273/+40
|
* Fix attribute access for the xrange objects. The tp_getattr and tp_getattroFred Drake2002-05-021-31/+38
| | | | | | handlers were both set, but were not compatible. This change uses only the tp_getattro handler with a more "modern" approach. This fixes SF bug #551285.
* Remove PyMalloc_New and PyMalloc_Del.Neil Schemenauer2002-04-121-2/+2
|
* Use pymalloc if it's enabled.Neil Schemenauer2002-03-221-2/+2
|
* Fix spelling mistakes. Bugfix candidates.Neal Norwitz2002-01-291-1/+1
|
* long_mul(): The PyNumber_Multiply() call can return a long if theGuido van Rossum2001-12-041-0/+6
| | | | | result would overflow an int. Check for this. (SF bug #488482, Armin Rigo.)
* repr's converted to using PyString_FromFormat() instead of sprintf'ingBarry Warsaw2001-08-241-19/+19
| | | | | | into a hardcoded char* buffer. Closes patch #454743.
* Patch #427190: Implement and use METH_NOARGS and METH_O.Martin v. Löwis2001-08-161-4/+1
|
* Merge of descr-branch back into trunk.Tim Peters2001-08-021-16/+28
|
* Re-add 'advanced' xrange features, adding DeprecationWarnings as discussedThomas Wouters2001-07-091-16/+219
| | | | | on python-dev. The features will still vanish, however, just one release later.
* Rip out the fancy behaviors of xrange that nobody uses: repeat, slice,Guido van Rossum2001-07-051-222/+15
| | | | | contains, tolist(), and the start/stop/step attributes. This includes removing the 4th ('repeat') argument to PyRange_New().
* SF patch #103158 by Greg Ball: Don't do unsafe arithmetic in xrangeGuido van Rossum2001-01-151-10/+80
| | | | | | | | | | | | | | | object. This fixes potential overflows in xrange()'s internal calculations on 64-bit platforms. The fix is complicated because the sq_length slot function can only return an int; we want to support xrange(sys.maxint), which is a 64-bit quantity on most 64-bit platforms (except Win64). The solution is hacky but the best possible: when the range is that long, we can use it in a for loop but we can't ask for its length (nor can we actually iterate beyond 2**31-1, because the sq_item slot function has the same restrictions on its arguments. Fixing those restrictions is a project for another day...
* Test for NULL returned from PyObject_NEW().Guido van Rossum2000-12-141-0/+3
|
* Fixed support for containment test when a negative step is used; thisFred Drake2000-11-081-8/+34
| | | | | | | *really* closes bug #121965. Added three attributes to the xrange object: start, stop, and step. These are the same as for the slice objects.
* In the containment test, get the boundary condition right. ">" was usedFred Drake2000-11-081-2/+2
| | | | | | where ">=" should have been. This closes bug #121965.
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* Boost buffer sizes in the absence of snprintf on Windows.Tim Peters2000-08-041-14/+19
| | | | Ensure that # of args to sprintf always matches # of format specifiers.
* snprintf() is not portable, so continue to use sprintf() until a portableFred Drake2000-08-041-8/+6
| | | | snprintf() is available.
* Remove the tp_print handler.Fred Drake2000-08-031-31/+27
| | | | | Revise the tp_repr handler to produce a more "minimal" presentation. Make the tolist() method use PyArg_ParseTuple() and provide a docstring.
* ANSI-fication of the sources.Fred Drake2000-07-091-36/+13
|
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
|
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
|
* Thomas Wouters <thomas@xs4all.net>:Fred Drake2000-06-151-0/+25
| | | | | | | | | | | | | | | The following patch adds "sq_contains" support to rangeobject, and enables the already-written support for sq_contains in listobject and tupleobject. The rangeobject "contains" code should be a bit more efficient than the current default "in" implementation ;-) It might not get used much, but it's not that much to add. listobject.c and tupleobject.c already had code for sq_contains, and the proper struct member was set, but the PyType structure was not extended to include tp_flags, so the object-specific code was not getting called (Go ahead, test it ;-). I also did this for the immutable_list_type in listobject.c, eventhough it is probably never used. Symmetry and all that.
* Vladimir Marangozov's long-awaited malloc restructuring.Guido van Rossum2000-05-031-1/+1
| | | | | | | | | | For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.)
* Use 'xrange', not 'range', in error messages. Reported by Nathan Sullivan.Guido van Rossum1999-01-091-3/+3
|
* Quickly renamed the last directory.Guido van Rossum1997-05-021-40/+41
|
* Make gcc -Wall happyGuido van Rossum1996-12-051-1/+1
|
* New permission notice, includes CNRI.Guido van Rossum1996-10-251-13/+20
|
* Use NEWOBJ() macro instead of calling newobject() directly.Guido van Rossum1996-07-221-1/+1
|