[Numpy-discussion] Response to PEP suggestions

Robert Kern rkern at ucsd.edu
Sat Feb 19 06:29:25 CST 2005


konrad.hinsen at laposte.net wrote:
> On 19.02.2005, at 05:37, Robert Kern wrote:
> 
>> I don't see the problem that this approach would solve. It doesn't  
>> solve the list/tuple indexing problem by itself. Even if the types 
>> are  part of the standard library, they won't be bona-fide ints, so 
>> the  indexing code would still have to be modified to check for them.
> 
> 
> Yes, but it could check for "integer type" (using the type hierarchy)  
> rather than convert everything to an integer with the problem that  
> Guido pointed out.

Except that these types probably can't be derived from the builtin int. 
The C layouts would have to be compatible. They'd probably have to be a 
separate hierarchy.

At that, rank-0 arrays would have to become a special case because their 
value will have to be reflected by x->ob_ival. And how that happens is 
going to depend on their actual C type. We'll be inheriting methods that 
we can't use, and general arrays, even if the C types are compatible, 
can't be used in place of a bona fide PyIntObject.

I would prefer a single type of array object that can store different 
kinds of values.

> However, my original motivation was consistency of usage. Python has  
> type objects to specify types, so I'd rather use them than introduce  
> another way to specify the type of array elements.

True. However, if we introduce a bona fide TypeObject hierarchy for 
numerical scalars that *can* be profitably used outside of the array 
context, it's *going* to be used outside of the array context. If it 
gets into the standard library, it can't just be a large number 
hierarchy for our use; it will have to be *the* number hierarchy for 
Python and include PyLongObjects and decimals and rationals.

And that's probably a bit more than we care to deal with to get 
multiarrays into the core.

On the other hand, the list/tuple indexing issue won't go away until the 
PEP is accepted and integrated into the core. And it won't be accepted 
until Numeric3 has had some life of it's own outside the standard library.

Bugger.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Numpy-discussion mailing list