Top Description Fields Constructors Methods
org.python.core

public Class PyXRange

extends PySequence
Class Inheritance
Annotations
@Untraversable
@ExposedType
name:xrange
base:PyObject
isBaseType:false
doc:xrange([start,] stop[, step]) -> xrange object Like range(), but instead of returning a list, returns an object that generates the numbers in the range on demand. For looping, this is slightly faster than range() and more memory efficient.
Imports
org.python.expose.ExposedMethod, .ExposedNew, .ExposedType, java.util.ArrayList, .Collection, .Iterator, .List

The builtin xrange type.

Field Summary

Modifier and TypeField and Description
private final long
private final long
private final long
private final long
public static final PyType
Inherited from org.python.core.PySequence:
delegator

Constructor Summary

AccessConstructor and Description
public
PyXRange(int ihigh)

public
PyXRange(int ilow, int ihigh)

public
PyXRange(int ilow, int ihigh, int istep)

Method Summary

Modifier and TypeMethod and Description
public PyObject
__getitem__(PyObject
the key to lookup in this container.
index
)

Overrides org.python.core.PySequence.__getitem__.

Equivalent to the standard Python __getitem__ method.

public PyObject
__iter__()

Overrides org.python.core.PySequence.__iter__.

Return an iterator that is used to iterate the element of this sequence.

public int
__len__()

Overrides org.python.core.PyObject.__len__.

Equivalent to the standard Python __len__ method.

public PyObject
__reduce__()

Overrides org.python.core.PyObject.__reduce__.

Used for pickling.

public Object
__tojava__(Class<?>
the Class to convert this PyObject to.
c
)

Overrides org.python.core.PySequence.__tojava__.

Equivalent to the Jython __tojava__ method.

pack-priv static int

Returns:

int length of range
getLenOfRange
(long
int value
lo
,
long
int value
hi
,
long
int value (> 0)
step
)

Return number of items in range/xrange (lo, hi, step).

protected PyObject
getslice(int
the position of the first element.
start
,
int
one more than the position of the last element.
stop
,
int
the step size.
step
)

Implements abstract org.python.core.PySequence.getslice.

Returns a range of elements from the sequence.

protected PyObject
pyget(int
index of element to return.
i
)

Implements abstract org.python.core.PySequence.pyget.

Returns the element of the sequence at the given index.

private final PyXRangeIter
private final PyXRangeIter
protected PyObject
repeat(int
the number of times to repeat the sequence.
howmany
)

Implements abstract org.python.core.PySequence.repeat.

Returns a (concrete subclass of) PySequence that repeats the given sequence, as in the implementation of __mul__ for strings.

public String
toString()

Overrides org.python.core.PyObject.toString.

Returns a string representation of the object.

protected String
unsupportedopMessage(String op, PyObject o2)

Overrides org.python.core.PySequence.unsupportedopMessage.

Return sequence-specific error messages suitable for substitution.

pack-priv final PyObject
public PyObject
pack-priv final int
pack-priv static final PyObject
xrange___new__(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)

public PyObject
public PyObject
Inherited from org.python.core.PySequence:
__delitem____delslice____eq____finditem____finditem____ge____getslice____gt____le____lt____ne____nonzero____setitem____setitem____setslice__boundToSequencecmpdeldelRangedelslicefastSequenceisMappingTypeisNumberTypeisSequenceTypeisSubTypepysetrunsupportedopMessageseq___delitem__seq___delslice__seq___eq__seq___finditem__seq___finditem__seq___ge__seq___getitem__seq___getslice__seq___gt__seq___iter__seq___le__seq___lt__seq___ne__seq___nonzero__seq___setitem__seq___setslice__setslicesliceLength

Field Detail

lenback to summary
private final long len
startback to summary
private final long start
stepback to summary
private final long step
stopback to summary
private final long stop
TYPEback to summary
public static final PyType TYPE

Hides org.python.core.PyObject.TYPE.

Constructor Detail

PyXRangeback to summary
public PyXRange(int ihigh)
PyXRangeback to summary
public PyXRange(int ilow, int ihigh)
PyXRangeback to summary
public PyXRange(int ilow, int ihigh, int istep)

Method Detail

__getitem__back to summary
public PyObject __getitem__(PyObject index)

Overrides org.python.core.PySequence.__getitem__.

Doc from org.python.core.PyObject.__getitem__.

Equivalent to the standard Python __getitem__ method. This method should not be overridden. Override the __finditem__ method instead.

Parameters
index:PyObject

the key to lookup in this container.

Returns:PyObject

the value corresponding to that key.

Annotations
@Override

__iter__back to summary
public PyObject __iter__()

Overrides org.python.core.PySequence.__iter__.

Doc from org.python.core.PyObject.__iter__.

Return an iterator that is used to iterate the element of this sequence. From version 2.2, this method is the primary protocol for looping over sequences.

If a PyObject subclass should support iteration based in the __finditem__() method, it must supply an implementation of __iter__() like this:

public PyObject __iter__() {
    return new PySequenceIter(this);
}
When iterating over a python sequence from java code, it should be done with code like this:
for (PyObject item : seq.asIterable()) {
    // Do something with item
}
Annotations
@Override
__len__back to summary
public int __len__()

Overrides org.python.core.PyObject.__len__.

Doc from org.python.core.PyObject.__len__.

Equivalent to the standard Python __len__ method. Part of the mapping discipline.

Returns:int

the length of the object

Annotations
@Override

__reduce__back to summary
public PyObject __reduce__()

Overrides org.python.core.PyObject.__reduce__.

Doc from org.python.core.PyObject.__reduce__.

Used for pickling. Default implementation calls object___reduce__.

Returns:PyObject

a tuple of (class, tuple)

Annotations
@Override

__tojava__back to summary
public Object __tojava__(Class<?> c)

Overrides org.python.core.PySequence.__tojava__.

Doc from org.python.core.PyObject.__tojava__.

Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special object Py.NoConversion if this PyObject can not be converted to the desired Java class.

Parameters
c:Class<?>

the Class to convert this PyObject to.

Annotations
@Override
getLenOfRangeback to summary
pack-priv static int getLenOfRange(long lo, long hi, long step)

Return number of items in range/xrange (lo, hi, step). step > 0 required. Return a value < 0 if & only if the true value is too large to fit in a Java int.

Parameters
lo:long

int value

hi:long

int value

step:long

int value (> 0)

Returns:int

int length of range

getsliceback to summary
protected PyObject getslice(int start, int stop, int step)

Implements abstract org.python.core.PySequence.getslice.

Doc from org.python.core.PySequence.getslice.

Returns a range of elements from the sequence.

Parameters
start:int

the position of the first element.

stop:int

one more than the position of the last element.

step:int

the step size.

Returns:PyObject

a sequence corresponding the the given range of elements.

Annotations
@Override

pygetback to summary
protected PyObject pyget(int i)

Implements abstract org.python.core.PySequence.pyget.

Doc from org.python.core.PySequence.pyget.

Returns the element of the sequence at the given index. This is an extension point called by PySequence in its implementation of __getitem__ It is guaranteed by PySequence that when it calls pyget(int) the index is within the bounds of the array. Any other clients must make the same guarantee.

Parameters
i:int

index of element to return.

Returns:PyObject

the element at the given position in the list.

Annotations
@Override

range_iterback to summary
private final PyXRangeIter range_iter()
range_reverseback to summary
private final PyXRangeIter range_reverse()
repeatback to summary
protected PyObject repeat(int howmany)

Implements abstract org.python.core.PySequence.repeat.

Doc from org.python.core.PySequence.repeat.

Returns a (concrete subclass of) PySequence that repeats the given sequence, as in the implementation of __mul__ for strings.

Parameters
howmany:int

the number of times to repeat the sequence.

Returns:PyObject

this sequence repeated count times.

Annotations
@Override

toStringback to summary
public String toString()

Overrides org.python.core.PyObject.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override

unsupportedopMessageback to summary
protected String unsupportedopMessage(String op, PyObject o2)

Overrides org.python.core.PySequence.unsupportedopMessage.

Doc from org.python.core.PySequence.unsupportedopMessage.

Return sequence-specific error messages suitable for substitution. {0} is the op name. {1} is the left operand type. {2} is the right operand type.

Annotations
@Override
xrange___getitem__back to summary
pack-priv final PyObject xrange___getitem__(PyObject index)
Annotations
@ExposedMethod
doc:x.__getitem__(y) <==> x[y]
xrange___iter__back to summary
public PyObject xrange___iter__()
Annotations
@ExposedMethod
doc:x.__iter__() <==> iter(x)
xrange___len__back to summary
pack-priv final int xrange___len__()
Annotations
@ExposedMethod
doc:x.__len__() <==> len(x)
xrange___new__back to summary
pack-priv static final PyObject xrange___new__(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)
Annotations
@ExposedNew
xrange___reduce__back to summary
public PyObject xrange___reduce__()
Annotations
@ExposedMethod
xrange___reversed__back to summary
public PyObject xrange___reversed__()
Annotations
@ExposedMethod
doc:Returns a reverse iterator.