From: <cg...@us...> - 2008-11-23 00:18:20
|
Revision: 5604 http://jython.svn.sourceforge.net/jython/?rev=5604&view=rev Author: cgroves Date: 2008-11-23 00:18:15 +0000 (Sun, 23 Nov 2008) Log Message: ----------- Assume any instance of PySequence has an accurate __len__. See http://www.nabble.com/PySequenceList-and-fastSequence-td14977175.html Modified Paths: -------------- trunk/jython/src/org/python/core/PySequence.java Modified: trunk/jython/src/org/python/core/PySequence.java =================================================================== --- trunk/jython/src/org/python/core/PySequence.java 2008-11-22 23:30:45 UTC (rev 5603) +++ trunk/jython/src/org/python/core/PySequence.java 2008-11-23 00:18:15 UTC (rev 5604) @@ -4,12 +4,12 @@ /** * The abstract superclass of PyObjects that implements a Sequence. Minimize the work in creating * such objects. - * + * * Method names are designed to make it possible for subclasses of PySequence to implement * java.util.List. - * + * * Subclasses must also implement get, getslice, and repeat methods. - * + * * Subclasses that are mutable should also implement: set, setslice, del, and delRange. */ public abstract class PySequence extends PyObject { @@ -19,7 +19,7 @@ */ public PySequence() {} public int gListAllocatedStatus = -1; - + protected PySequence(PyType type) { super(type); } @@ -34,7 +34,7 @@ /** * Returns a range of elements from the sequence. - * + * * @param start * the position of the first element. * @param stop @@ -47,7 +47,7 @@ /** * Repeats the given sequence. - * + * * @param count * the number of times to repeat the sequence. * @return this sequence repeated count times. @@ -57,7 +57,7 @@ // These methods only apply to mutable sequences /** * Sets the given element of the sequence. - * + * * @param index * index of the element to set. * @param value @@ -217,9 +217,9 @@ } // Return a copy of a sequence where the __len__() method is - // telling the thruth. + // telling the truth. protected static PyObject fastSequence(PyObject seq, String msg) { - if(seq instanceof PyList || seq instanceof PyTuple) { + if(seq instanceof PySequence) { return seq; } PyList list = new PyList(); @@ -430,7 +430,7 @@ /** * 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. */ protected String unsupportedopMessage(String op, PyObject o2) { @@ -442,7 +442,7 @@ /** * 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. */ protected String runsupportedopMessage(String op, PyObject o2) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |