[Numpy-discussion] numpy array change notifier?
Brent Pedersen
bpederse@gmail....
Mon Oct 27 18:54:33 CDT 2008
On Mon, Oct 27, 2008 at 2:45 PM, Ryan May <rmay31@gmail.com> wrote:
> Brent Pedersen wrote:
>> On Mon, Oct 27, 2008 at 1:56 PM, Robert Kern <robert.kern@gmail.com> wrote:
>>> On Mon, Oct 27, 2008 at 15:54, Erik Tollerud <erik.tollerud@gmail.com> wrote:
>>>> Is there any straightforward way of notifying on change of a numpy
>>>> array that leaves the numpy arrays still efficient?
>>> Not currently, no.
>>>
>>> --
>>> Robert Kern
>>>
>>> "I have come to believe that the whole world is an enigma, a harmless
>>> enigma that is made terrible by our own mad attempt to interpret it as
>>> though it had an underlying truth."
>>> -- Umberto Eco
>>> _______________________________________________
>>> Numpy-discussion mailing list
>>> Numpy-discussion@scipy.org
>>> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>>>
>>
>> out of curiosity,
>> would something like this affect efficiency (and/or work):
>>
>> class Notify(numpy.ndarray):
>> def __setitem__(self, *args):
>> self.notify(*args)
>> return super(Notify, self).__setitem__(*args)
>>
>> def notify(self, *args):
>> print 'notify:', args
>>
>>
>> with also overriding setslice?
>
> I haven't given this much thought, but you'd also likely need to do this
> for the infix operators (+=, etc.).
>
> Ryan
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
ah. i didnt think of that. i guess one could loop through dir(self) in
__init__ and apply a wrapper to a list of method names or to all
callables.
More information about the Numpy-discussion
mailing list