Class PySlice

All Implemented Interfaces:
Serializable, Traverseproc

public class PySlice extends PyObject implements Traverseproc
The Python slice object.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class PyObject
    • __eq__

      public PyObject __eq__(PyObject o)
      Description copied from class: PyObject
      Equivalent to the standard Python __eq__ method.
      Overrides:
      __eq__ in class PyObject
      Parameters:
      o - the object to compare this with.
      Returns:
      the result of the comparison.
    • __ne__

      public PyObject __ne__(PyObject o)
      Description copied from class: PyObject
      Equivalent to the standard Python __ne__ method.
      Overrides:
      __ne__ in class PyObject
      Parameters:
      o - the object to compare this with.
      Returns:
      the result of the comparison.
    • indices

      public PyObject indices(PyObject len)
    • indicesEx

      public int[] indicesEx(int length)
      Calculates the actual indices of a slice with this slice's start, stop, step and slicelength values for a sequence of length len.
      Returns:
      an array with the start at index 0, stop at index 1, step at index 2 and slicelength at index 3
    • indices2

      public static PyObject[] indices2(PyObject obj, PyObject start, PyObject stop)
      Calculate indices for the deprecated __get/set/delslice__ methods.
      Parameters:
      obj - the object being sliced
      start - the slice operation's start
      stop - the slice operation's stop
      Returns:
      an array with start at index 0 and stop at index 1
    • calculateSliceIndex

      public static int calculateSliceIndex(PyObject v)
    • toString

      public String toString()
      Overrides:
      toString in class PyObject
    • getStart

      public final PyObject getStart()
    • getStop

      public final PyObject getStop()
    • getStep

      public final PyObject getStep()
    • traverse

      public int traverse(Visitproc visit, Object arg)
      Description copied from interface: Traverseproc
      Traverses all directly contained PyObjects. Like in CPython, arg must be passed unmodified to visit as its second parameter. If Visitproc.visit(PyObject, Object) returns nonzero, this return value must be returned immediately by traverse. Visitproc.visit(PyObject, Object) must not be called with a null PyObject-argument.
      Specified by:
      traverse in interface Traverseproc
    • refersDirectlyTo

      public boolean refersDirectlyTo(PyObject ob)
      Description copied from interface: Traverseproc
      Optional operation. Should only be implemented if it is more efficient than calling Traverseproc.traverse(Visitproc, Object) with a visitproc that just watches out for ob. Must return false if ob is null.
      Specified by:
      refersDirectlyTo in interface Traverseproc