[Python-Dev] Bad interaction of index and sequence repeat (original) (raw)

Michael Hudson mwh at python.net
Fri Jul 28 17:26:37 CEST 2006


David Hopwood <david.nospam.hopwood at blueyonder.co.uk> writes:

Armin Rigo wrote:

Hi,

There is an oversight in the design of index() that only just surfaced :-( It is responsible for the following behavior, on a 32-bit machine with >= 2GB of RAM: >>> s = 'x' * (2**100) # works! >>> len(s) 2147483647 This is because PySequenceRepeat(v, w) works by applying w.index in order to call v->sqrepeat. However, index is defined to clip the result to fit in a Pyssizet. Clipping the result sounds like it would never be a good idea. What was the rationale for that? It should throw an exception.

Why would you expect range(10)[:232-1] and range(10)[:232] to do different things?

Cheers, mwh

-- This makes it possible to pass complex object hierarchies to a C coder who thinks computer science has made no worthwhile advancements since the invention of the pointer. -- Gordon McMillan, 30 Jul 1998



More information about the Python-Dev mailing list