Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-31 Thread Kyle Lahnakoski
Julien, Personally, I would be able to use the module you are proposing to accumulate arbitrarily-named measures. I can not think of a use case for division, but it would be nice for completion.  I have made my own library that implements a small part of what you propose [1]. I was looking

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-31 Thread Robert Vanden Eynde
And with libraries like pip install funcoperators or pip install infix, you can even write it infix :D from funcoperators import infix @infix def superop(d1, sc): return {k: (v *superopp* sc) for k, v in d1.items()} print({'a': 8} *superop* 5) Le mer. 31 oct. 2018 à 18:35, Vladimir

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-31 Thread Vladimir Filipović
Julien, would I be correct if I summarized the changes you have in mind like this: for dictionaries d1 and d2, non-Mapping ("scalar") sc, binary operation ⊛, and unary operation 퓊 (such as negation or abs()): d1 ⊛ sc == {k: (v ⊛ sc) for k, v in d1.items()} sc ⊛ d1 == {k: (sc ⊛ v) for k, v in

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread julien tayon
On Wed, 31 Oct 2018 at 00:20, David Mertz wrote: > Counter doesn't QUITE do the same thing as this `mdict`. But it's pretty > close. > > I think if .__add__() became a synonym for .update() that wouldn't break > anything that currently works. But I'm probably wrong, and missing a case > in my

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread David Mertz
Actually, they are definitely different as in-place mutation versus returning a new Counter. But in some arithmetic way they look mostly the same. On Tue, Oct 30, 2018, 7:19 PM David Mertz Counter doesn't QUITE do the same thing as this `mdict`. But it's pretty > close. > > I think if

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread David Mertz
Counter doesn't QUITE do the same thing as this `mdict`. But it's pretty close. I think if .__add__() became a synonym for .update() that wouldn't break anything that currently works. But I'm probably wrong, and missing a case in my quick thought: >>> from collections import Counter >>> c =

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread Alexander Belopolsky
> In [12]: a= mdict(a=[2], b='a') > In [13]: a+a Aren't you reinventing the Counter type? >>> from collections import Counter >>> c = Counter(a=1,b=2) >>> c + c Counter({'b': 4, 'a': 2}) ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread julien tayon
On Tue, 30 Oct 2018 at 22:33, Greg Ewing wrote: > julien tayon wrote: > > like the + of [] could be the + of "RecordAlgebrae" > > If you're proposing to change the behaviour of '+' on the > built-in list type, that's not going to happen. > > I dont suggest to change something that already exists

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread Greg Ewing
julien tayon wrote: like the + of [] could be the + of "RecordAlgebrae" If you're proposing to change the behaviour of '+' on the built-in list type, that's not going to happen. -- Greg ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread julien tayon
Thanks robert for the praise. It feels nice. I may be bold, but I really hate to come empty handed to a discussion. So this lib is nothing more than doing my homework when I don't have a PhD. Actually, science (in my opinion) is about measuring. What I propose is nothing more than (if you add

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread Robert Vanden Eynde
Julien, your article is very pleasant to read (and funny) but as other say the mailing list is not there to share some articles, but for proposition to the standard python library, do our own lib on github and pypi first if you want to Share some code to the world ! And if project becomes super

Re: [Python-ideas] Implementing a set of operation (+, /, - *) on dict consistent with linearAlgebrae

2018-10-30 Thread Anders Hovmöller
> What are your opinions ? > I don't actually see a lot of use case except it was funny to build. But > maybe it can be of use. This list is for suggesting additions and changes to python. Broad usefulness is a prerequisite. So please build your lib but this seems off topic on this list. /