Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Sub-classing NumArray - two questions (http://www.velocityreviews.com/forums/t323108-sub-classing-numarray-two-questions.html)

Colin J. Williams 10-01-2003 04:04 PM

Sub-classing NumArray - two questions
 
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/l...mpy-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



All times are GMT. The time now is 05:08 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.