Sub-classing NumArray - two questions
Colin J. Williams
cjw at sympatico.ca
Wed Oct 1 12:04:23 EDT 2003
More information about the Python-list mailing list
Wed Oct 1 12:04:23 EDT 2003
- Previous message (by thread): [ANN] Trie for Python
- Next message (by thread): appending to list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
numarray is a package which is under development and intended to replace Numeric, an efficient and operational package. One of the classes in numarray is NumArray. As currently implemented, instances of this class are instantiated using factory functions. This appears to restrict the sub-classing of NumArray Examples: a sub-class Matrix, an array restricted to two dimensions, or a sub-class Mix, which combines the NumArray with RecArray (another class in the numarray package), or even a sub-class of matrix, Symmetric (to use more efficient storage) These cannot readily be built using factory functions. This has been discussed on the NumPy list (http://lists.sourceforge.net/lists/listinfo/numpy-discussion) and the question was posed: Q1 Can someone please explain what the "new-classes standard" is? (Obviously meeting it is not one of our current goals) Another related question: Q2 It seems that certain flaws were perceived in Numeric (NumPy), developed in 1997 by Jim Hugunin. Development of numarray was started to produce an array package which could become a standard Python package. What were the flaws seen in Numeric? Colin W. Background from the NumPY list: Regarding the "new-classes standard", I can't find much in either the Python docs or Alex Martelli's "Python in a Nutshell". One of the new features is a __new__ constructor. The Python array module doesn't formally have a class and thus it can't be sub-classed. It uses a factory function to create instance objects. Martelli, in PIAN p74, writes of factory functions being useful when one wishes to create instances of different classes depending on some condition or for the reuse of an existing instance. In the Python Cookbook p173, he proposes the use of a factory function to get around the limitations of Python 2.1 and earlier. On page 179, he refers to the use of a factory method, again to work around limitations before Python 2.2. My rough and ready definition would include the ability to create an instance and initialize the data in one step. cjw -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20031001/f0e30c5b/attachment.html>
- Previous message (by thread): [ANN] Trie for Python
- Next message (by thread): appending to list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list