← Back to team overview

python-quantities-developers team mailing list archive

Re: In place arithmetic

 

I'm looking into adding in-place arithmetic back in...

On Mon, Jan 19, 2009 at 3:48 PM, Darren Dale <dsdale24@xxxxxxxxx> wrote:

> I experimented with that approach for most of the morning yesterday. The
> problem is that lots of operations that create new Quantity objects, like
> multiplication, yield an object that you would think owns its own data, but
> in fact does not. I asked about it on the numpy mailing list, and Robert
> Kern suggested that it would probably be best to simply disallow in-place
> modification of units.
>
> Robert said it might be possible to check if q.base is an instance of
> Quantity, and I had been trying that approach, but the arithmetic operations
> yield an object whose base is an ndarray, when we would be counting on the
> base being None or a Quantity. If we can find a way to yield objects that
> own their own data, without additional overhead of creating additional
> copies of the data, then I think we could allow in-place operations.
> otherwise, we choose between forbidding them, or allowing them but warning
> people that in-place operations are potentially dangerous.
>
> Darren
>
> P.S. please respond to the mailing list so we can capture these
> considerations in the mailing list archives
>
>
> On Sun, Jan 18, 2009 at 10:29 PM, John Salvatier <
> jsalvati@xxxxxxxxxxxxxxxx> wrote:
>
>> That would be the only case when it's not ambiguous, really.
>>
>>
>> On Sun, Jan 18, 2009 at 7:28 PM, John Salvatier <
>> jsalvati@xxxxxxxxxxxxxxxx> wrote:
>>
>>> Would it work to support in place arithmetic only for cases when the
>>> array is the owner of the data (basically is not a view)?
>>>
>>>
>>> On Sun, Jan 18, 2009 at 7:22 PM, Darren Dale <dsdale24@xxxxxxxxx> wrote:
>>>
>>>> I looked at it for quite a while today, and I dont think there is a safe
>>>> way to support it. I could consider adding it back in if there is a big
>>>> demand for it. I think I remember you suggested not allowing in-place
>>>> modification of units in one of our first discussions, and I've finally come
>>>> around to that point of view.
>>>>
>>>> We can still allow in-place arithmetic that doesnt modify the units.
>>>>
>>>> I just pushed some big changes in the constants subpackage up to
>>>> launchpad.
>>>>
>>>> Darren
>>>>
>>>> On Sun, Jan 18, 2009 at 9:53 PM, John Salvatier <
>>>> jsalvati@xxxxxxxxxxxxxxxx> wrote:
>>>>
>>>>> I see your latest update about not allowing in-place arithmetic. Do you
>>>>> think this is something we should support eventually? It's not something I
>>>>> generally use, but it seems like something that is important for some
>>>>> people.
>>>>>
>>>>> _______________________________________________
>>>>> Mailing list: https://launchpad.net/~python-quantities-developers<https://launchpad.net/%7Epython-quantities-developers>
>>>>> Post to     : python-quantities-developers@xxxxxxxxxxxxxxxxxxx
>>>>> Unsubscribe : https://launchpad.net/~python-quantities-developers<https://launchpad.net/%7Epython-quantities-developers>
>>>>> More help   : https://help.launchpad.net/ListHelp
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Mailing list: https://launchpad.net/~python-quantities-developers<https://launchpad.net/%7Epython-quantities-developers>
>>>> Post to     : python-quantities-developers@xxxxxxxxxxxxxxxxxxx
>>>> Unsubscribe : https://launchpad.net/~python-quantities-developers<https://launchpad.net/%7Epython-quantities-developers>
>>>> More help   : https://help.launchpad.net/ListHelp
>>>>
>>>>
>>>
>>
>

References