Ejemplo n.º 1
0
  // Return a copy of a sequence where the __len__() method is
  // telling the thruth.
  protected static PyObject fastSequence(PyObject seq, String msg) {
    if (seq instanceof PyList || seq instanceof PyTuple) return seq;

    if (!seq.isSequenceType()) throw Py.TypeError(msg);

    PyList list = new PyList();
    PyObject iter = Py.iter(seq, msg);
    for (PyObject item = null; (item = iter.__iternext__()) != null; ) {
      list.append(item);
    }
    return list;
  }