Re: [Numpy-discussion] Addition of a dict object to all NumPy objects

2008-08-16 Thread Robert Kern
On Fri, Aug 15, 2008 at 19:30, Christian Heimes [EMAIL PROTECTED] wrote: Please also note that CPython uses a freelist of unused dict instances. The default size of the dict free list is 80 elements. The allocation and deallocation of dicts is cheap if you can stay below the threshold. That's

Re: [Numpy-discussion] Addition of a dict object to all NumPy objects

2008-08-15 Thread Charles R Harris
On Fri, Aug 15, 2008 at 1:58 PM, Travis E. Oliphant [EMAIL PROTECTED]wrote: Hello all, While we are on the subject of C-API changes, I've noticed that quite a few of the sub-classes of ndarray are constructed to basically add meta-information to the array. What if the base-class ndarray

Re: [Numpy-discussion] Addition of a dict object to all NumPy objects

2008-08-15 Thread Charles R Harris
On Fri, Aug 15, 2008 at 2:10 PM, Charles R Harris [EMAIL PROTECTED] wrote: On Fri, Aug 15, 2008 at 1:58 PM, Travis E. Oliphant [EMAIL PROTECTED] wrote: Hello all, While we are on the subject of C-API changes, I've noticed that quite a few of the sub-classes of ndarray are constructed

Re: [Numpy-discussion] Addition of a dict object to all NumPy objects

2008-08-15 Thread Robert Kern
On Fri, Aug 15, 2008 at 15:15, Charles R Harris [EMAIL PROTECTED] wrote: On Fri, Aug 15, 2008 at 2:10 PM, Charles R Harris [EMAIL PROTECTED] wrote: On Fri, Aug 15, 2008 at 1:58 PM, Travis E. Oliphant [EMAIL PROTECTED] wrote: Hello all, While we are on the subject of C-API changes, I've

Re: [Numpy-discussion] Addition of a dict object to all NumPy objects

2008-08-15 Thread Travis E. Oliphant
Robert Kern wrote: 3) Are the additional 4-8 bytes too expensive One of the problems with numarray was the time taken to allocate small arrays. Would adding a dictionary slow down the allocation of numpy arrays? No, I don't think so, not if we did nothing by default but set

Re: [Numpy-discussion] Addition of a dict object to all NumPy objects

2008-08-15 Thread Charles R Harris
On Fri, Aug 15, 2008 at 3:12 PM, Travis E. Oliphant [EMAIL PROTECTED]wrote: Robert Kern wrote: 3) Are the additional 4-8 bytes too expensive One of the problems with numarray was the time taken to allocate small arrays. Would adding a dictionary slow down the allocation of numpy

Re: [Numpy-discussion] Addition of a dict object to all NumPy objects

2008-08-15 Thread Christian Heimes
Robert Kern wrote: I think you could make the dictionary created lazily on the first getattr(). In order to make it work you have to reserve space for a PyObject* pointer for the instance dict somewhere in your type definition. It's going to increase the size of every object by 4 bytes on a

Re: [Numpy-discussion] Addition of a dict object to all NumPy objects

2008-08-15 Thread Robert Kern
On Fri, Aug 15, 2008 at 17:31, Christian Heimes [EMAIL PROTECTED] wrote: Robert Kern wrote: I think you could make the dictionary created lazily on the first getattr(). In order to make it work you have to reserve space for a PyObject* pointer for the instance dict somewhere in your type

Re: [Numpy-discussion] Addition of a dict object to all NumPy objects

2008-08-15 Thread Christian Heimes
Robert Kern wrote: Yes, we know that. The concern I was addressing was the time overhead for creating the new dict object every time an ndarray gets instantiated. Most of these dict objects would be unused, so we would be wasting a substantial amount of time. If you push off the creation of