Sub-classing NumArray - two questions

Discussion in 'Python' started by Colin J. Williams, Oct 1, 2003.

  1. 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
     
    Colin J. Williams, Oct 1, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pritam Kamat

    Obfuscation and sub classing

    Pritam Kamat, Aug 8, 2003, in forum: Java
    Replies:
    2
    Views:
    533
    pete kirkham
    Aug 8, 2003
  2. Bernard Lebel

    Problem with sub-classing

    Bernard Lebel, Jul 17, 2006, in forum: Python
    Replies:
    3
    Views:
    379
    Peter Otten
    Jul 17, 2006
  3. Colin J. Williams
    Replies:
    1
    Views:
    279
    Michael Amrhein
    Aug 15, 2007
  4. Colin J. Williams
    Replies:
    5
    Views:
    335
    Colin J. Williams
    Aug 17, 2007
  5. Torsten Bronger
    Replies:
    9
    Views:
    271
    Martin v. Löwis
    Dec 31, 2007
Loading...

Share This Page