Is it possible we may just want to get rid of Jython's own array-based implementation (as realized through a fair amount of work, as David points out, in PySequenceList) in favor of using ArrayList (and perhaps other concrete implementations of List)? This had been investigated earlier ( http://wiki.python.org/jython/CollectionsIntegration), and the answer then was no, but I don't know how much of this was based on efficiently supporting Java 1.4 and earlier.

Of course this is not an immediate priority: this code is working, and we'd want to benchmark against any changes. But at least we have good unit tests to validate any changes.

However, it would suggest that if you're working with PySequenceList outside of the Jython core, you might be depending too much on Jython's internal implementation.

- Jim

On Jan 19, 2008 5:44 PM, David Morley <morley@ai.sri.com> wrote:
I am looking through the Jython PyTuple and PyList classes and I have
a few questions/suggestions:

(1) I notice that each PySequenceList (such as a PyTuple or PyList)
has an instance of PyObjectList, which has a PyObjectArray, which has
a PyObject[]. Thus each new PySequenceList requires the allocation of
an array and three Java objects. This also means that calling
PySequenceList's pyget method calls PyObjectLists's pyget method,
which calls PyObjectArray's get method, which accesses the underlying
array. Shouldn't it be possible to fold all this into PySequenceList,
so that it has a PyObject[] directly? I presume there is some reason
why this isn't done, I just don't know what it is.

(2) The fastSequence static method of PySequence trusts the PyList
and PyTuple __len__ methods to tell the truth about their lengths.
Would it be possible to introduce a new interface that both PyList
and PyTuple implement and have fastSequence test for this interface
rather than PyTuple or PyList? This would allow other, user-defined
subclasses of PySequence to share this behavior.

(3) Where the fastSequence static method of PySequence is not able to
return the given sequence, it could test whether the sequence
implements the List interface and if so, use the toArray method to
construct a PyObject[] rather than constructing an empty list and
appending to it.

If any of these suggestions sound reasonable, I would be happy to try
implementing them myself and submitting patches.

- David

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jython-dev mailing list
Jython-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-dev



--
Jim Baker
jbaker@zyasoft.com