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 https://mail

Re: [Python-ideas] Shuffled

2016-09-07 Thread Alexander Belopolsky
On Wed, Sep 7, 2016 at 6:56 PM, Arek Bulski wrote: > In the project I maintain (construct) there are declarative testcases that > look like a long list of (func, args, excepted output, error type) tuples. > There is no way for me to call shuffle in there. Can you explain why? Something like th

Re: [Python-ideas] Shuffled

2016-09-07 Thread Alexander Belopolsky
On Wed, Sep 7, 2016 at 8:14 PM, Arek Bulski wrote: > > If you want to see the declarative tests, here it is. > https://github.com/construct/construct/blob/master/tests/test_all.py So, why can't you call random.shuffle(all_tests) if you want to run your tests in random order? If for some reason

Re: [Python-ideas] Shuffled

2016-09-07 Thread Alexander Belopolsky
On Wed, Sep 7, 2016 at 9:12 PM, Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: > On Wed, Sep 7, 2016 at 8:14 PM, Arek Bulski wrote: > > > > If you want to see the declarative tests, here it is. > > https://github.com/construct/construct/blob/master/test

Re: [Python-ideas] Shuffled

2016-09-08 Thread Alexander Belopolsky
> On Sep 8, 2016, at 5:34 AM, Arek Bulski wrote: > > > So, why can't you call random.shuffle(all_tests) if you want to run your > > tests in random order? > > I dont randomize test order. People should stop assuming that they know > better. That's the best I could do given the minimal explan

Re: [Python-ideas] Null coalescing operator

2016-09-10 Thread Alexander Belopolsky
On Sat, Sep 10, 2016 at 4:56 PM, Guido van Rossum wrote: > Another issue already discussed in PEP 505 is a conflict with IPython > (Jupyter Notebook), which uses ? and ?? as custom syntax to request > help. But maybe it can be taught to only recognize those when they're > the last character(s) on

Re: [Python-ideas] typing.modifiers

2016-09-16 Thread Alexander Belopolsky
On Fri, Sep 16, 2016 at 1:39 PM, Chris Angelico wrote: > If people can't cite names using Hebrew > script, that's their problem, not yours. :) > https://hg.python.org/cpython/rev/0308f97616a3 Enjoy! ___ Python-ideas mailing list Python-ideas@python.or

Re: [Python-ideas] Make partial a built-in

2016-09-20 Thread Alexander Belopolsky
On Tue, Sep 20, 2016 at 11:51 AM, Guido van Rossum wrote: > Also, I once timed it and could not show that partial was faster. This > surprised me but it was what I measured (in one particular case). I did similar timings on several occasions in the past and was also surprised by the results. L

Re: [Python-ideas] Delay evaluation of annotations

2016-09-22 Thread Alexander Belopolsky
On Thu, Sep 22, 2016 at 1:19 PM, אלעזר wrote: > I propose delaying evaluation of annotation-expressions by either keeping > the AST of the annotation, or turning it implicitly from EXP into "lambda: > EXP". Inspection code that is interested in this information can access it > be calling (or eval

Re: [Python-ideas] Delay evaluation of annotations

2016-09-22 Thread Alexander Belopolsky
On Thu, Sep 22, 2016 at 3:58 PM, David Mertz wrote: > It's more verbose, but you can also spell it now as: > > class A: > def __add__(self, other: type(self)) -> type(self): ... > No, you can't: >>> class A: ... def __add__(self, other: type(self)) -> type(self): ... ... Traceback (most

Re: [Python-ideas] Delay evaluation of annotations

2016-09-22 Thread Alexander Belopolsky
On Thu, Sep 22, 2016 at 4:29 PM, אלעזר wrote: > Just as a demonstration, the parser can transform `EXP` into `lambda: EXP` > - and that's it. It will not solve everything (e.g. error messages and > .__annotation__ access as Alexander says), but it demonstrates the fact > that the change need not

Re: [Python-ideas] Delay evaluation of annotations

2016-09-22 Thread Alexander Belopolsky
On Thu, Sep 22, 2016 at 4:37 PM, Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: > On the second thought, why can't the parser simply replace A with 'A' in > annotations that appear in the body of class A? This will only break > somewhat pathological

Re: [Python-ideas] Delay evaluation of annotations

2016-09-22 Thread Alexander Belopolsky
On Thu, Sep 22, 2016 at 4:43 PM, Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: > > On Thu, Sep 22, 2016 at 4:37 PM, Alexander Belopolsky < > alexander.belopol...@gmail.com> wrote: > >> On the second thought, why can't the parser simply replac

Re: [Python-ideas] INSANE FLOAT PERFORMANCE!!!

2016-10-12 Thread Alexander Belopolsky
On Wed, Oct 12, 2016 at 5:57 PM, Elliot Gorokhovsky < elliot.gorokhov...@gmail.com> wrote: > On Wed, Oct 12, 2016 at 3:51 PM Nathaniel Smith wrote: > >> But this isn't relevant to Python's str, because Python's str never uses >> UTF-8. >> > > Really? I thought in python 3, strings are all unicode

Re: [Python-ideas] INSANE FLOAT PERFORMANCE!!!

2016-10-12 Thread Alexander Belopolsky
On Wed, Oct 12, 2016 at 6:14 PM, Elliot Gorokhovsky < elliot.gorokhov...@gmail.com> wrote: > so then Latin1 strings are memcmp-able, and others are not. No. Strings of the same kind are "memcmp-able" regardless of their kind. ___ Python-ideas mailing

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Alexander Belopolsky
On Wed, Oct 19, 2016 at 7:48 PM, Chris Barker wrote: > > > However, if you really don't like it, then you can pass a string to aconfsturctor function instead: > > a = arr_from_string(" | 0, 1, 2 || 3, 4, 5 | ") > > yeah, you need to type the extra quotes, but that's not much. > > NOTE: I'm pretty

Re: [Python-ideas] Contribution Reward System

2016-11-22 Thread Alexander Belopolsky
On Mon, Nov 21, 2016 at 10:17 PM, Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > One practice that worked pretty well as motivation a few years ago was > "review exchange" where a committer would offer one patch review in > return for confirmation and triage of five new issues

Re: [Python-ideas] Input characters in strings by decimals (Was: Proposal for default character representation)

2016-12-07 Thread Alexander Belopolsky
On Wed, Dec 7, 2016 at 9:07 PM, Mikhail V wrote: > > it somehow settled in > peoples' minds that hex reference should be preferred, for no solid reason IMO. I may be showing my age, but all the facts that I remember about ASCII codes are in hex: 1. SPACE is 0x20 followed by punctuation symbols.

Re: [Python-ideas] Enhancing vars()

2016-12-12 Thread Alexander Belopolsky
On Mon, Dec 12, 2016 at 6:45 PM, Steven D'Aprano wrote: > Proposal: enhance vars() to return a proxy to the object namespace, > regardless of whether said namespace is __dict__ itself, or a number of > __slots__, or both. > How do you propose dealing with classes defined in C? Their objects don

Re: [Python-ideas] Python reviewed

2017-01-09 Thread Alexander Belopolsky
On Mon, Jan 9, 2017 at 8:12 PM, Simon Lovell wrote: > Re: Colons. I'm sure I've seen that FAQ before. I may be arrogant but I > can't take it seriously. Being "slightly" easier to read is hardly a reason > for a mandatory structure. > "Readability counts." Did you notice that you placed a redun

Re: [Python-ideas] Python reviewed

2017-01-09 Thread Alexander Belopolsky
On Mon, Jan 9, 2017 at 8:19 PM, Chris Barker wrote: > > I think maybe by Dijkstra of C++ fame. Dijkstra is famous for many things, but C++ is another Dutchman's fault. Dijkstra's famous works include "GOTO Considered Harmful" [1] and "How do we tell truths that might hurt?" [2]. [1]: http://wik

Re: [Python-ideas] namedtuple with ordereddict

2017-07-19 Thread Alexander Belopolsky
On Wed, Jul 19, 2017 at 12:10 PM, Giampaolo Rodola' wrote: > Should have been something like this instead: > > $ python3.7 -m timeit -s "import collections; Point = > collections.namedtuple('Point', ('x', 'y')); x = [5, 1]" "Point(*x)" > 100 loops, best of 5: 311 nsec per loop > > $ python3.

Re: [Python-ideas] namedtuple literals [Was: RE a new namedtuple]

2017-07-19 Thread Alexander Belopolsky
On Wed, Jul 19, 2017 at 9:08 PM, Guido van Rossum wrote: > The proposal in your email seems incomplete The proposal does not say anything about type((x=1, y=2)). I assume it will be the same as the type currently returned by namedtuple(?, 'x y'), but will these types be cached? Will type((x=1, y

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Alexander Belopolsky
On Mon, Oct 30, 2017 at 11:44 AM, Nick Coghlan wrote: .. > 3. We can't replicate it as readily in the regular REPL, since that runs > Python code directly in the current process, but even there I believe we > could potentially trigger a full process restart via execve (or the C++ > style _execve o

Re: [Python-ideas] pdb to support running modules

2018-01-09 Thread Alexander Belopolsky
On Thu, Jan 4, 2018 at 8:15 PM, Guido van Rossum wrote: > Sounds uncontroversial, this can just be done via bugs.python.org. > .. and it has been proposed there over 7 years ago: . ___ Python-ideas mailing list Python-

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-04 Thread Alexander Belopolsky
On Fri, May 4, 2018 at 8:06 AM, Nick Coghlan wrote: > ... > With that spelling, the three examples above would become: > > # Exactly one branch is executed here > if m given m = pattern.search(data): > ... > elif m given m = other_pattern.search(data)): > ... > else

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-10 Thread Alexander Belopolsky
On Thu, May 10, 2018 at 9:44 AM, Guido van Rossum wrote: > I'm sorry, but unless there's a sudden landslide of support for 'given' in > favor of ':=', I'm really not going to consider it. How much support was there for ":="? Are you serious about bringing back Pascal and Algol from their comfort

Re: [Python-ideas] High Precision datetime

2018-05-10 Thread Alexander Belopolsky
> Is there interest in a PEP for extending time, datetime / timedelta for arbitrary or extended precision fractional seconds? Having seen the utter disaster that similar ideas brought to numpy, I would say: no. On the other hand, nanoseconds are slowly making their way to the stdlib and to add na

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-11 Thread Alexander Belopolsky
On Fri, May 11, 2018 at 11:43 AM Steven D'Aprano wrote: > ... > I agree with Jacco here. We have to name the variable twice, even if it > is only used once, and we have a relatively long keyword, five > characters, longer than average for all keywords, and only one char > short of the maximum. To

Re: [Python-ideas] High Precision datetime

2018-05-17 Thread Alexander Belopolsky
On Thu, May 17, 2018 at 12:56 PM Chris Barker via Python-ideas < python-ideas@python.org> wrote: > The other issue with leap-seconds is that python's datetime doesn't support them :-) That's not entirely true. Since the implementation of PEP 495, it is possible to represent the 23:59:60 as 23:59

Re: [Python-ideas] High Precision datetime

2018-05-17 Thread Alexander Belopolsky
On Thu, May 17, 2018 at 1:33 PM Chris Barker wrote: > > On Thu, May 17, 2018 at 10:14 AM, Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: >> [...] Since the implementation of PEP 495, it is >> possible to represent the 23:59:60 as 23:59:59 with the "fol

Re: [Python-ideas] High Precision datetime

2018-05-17 Thread Alexander Belopolsky
On Thu, May 17, 2018 at 2:51 PM Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: > > TAI | UTC > -+ > 2016-12-31T23:59:35 | 2016-12-31T23:59:59 > 2016-12-31T23:59:36 | 2016-12-31T23:59:60 > 2016-1

Re: [Python-ideas] High Precision datetime

2018-05-17 Thread Alexander Belopolsky
On Thu, May 17, 2018 at 3:13 PM Tim Peters wrote: > [Chris Barker] > > Does that support the other way -- or do we never lose a leap second > anyway? > > (showing ignorance here) > > Alexander covered the Python part of this, ... > No, I did not. I did not realize that the question was about s

Re: [Python-ideas] High Precision datetime

2018-05-17 Thread Alexander Belopolsky
On Thu, May 17, 2018 at 7:12 PM Wes Turner wrote: > AstroPy solves for leap seconds [1][2] according to the IAU ERFA (SOFA) > library [3] and the IERS-B and IERS-A tables [4]. IERS-B tables ship with > AstroPy. The latest IERS-A tables ("from 1973 though one year into the > future") auto-download

[Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Alexander Belopolsky
I have read most of the PEP 572 related threads, but I don't think I've seen this idea. As many other people mentioned, Python already allows a trick to introduce local bindings in generator expressions and list comprehensions. This can be achieved by adding a "for var in []" clause. I propose t

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Alexander Belopolsky
On Thu, May 24, 2018 at 12:04 PM Robert Vanden Eynde wrote: > This idea was mentioned (by me) at a time yes, but wasn't written in the document. Can you point me to a specific post? There were so may that I must have missed that one. > I think one of the thing was that it would make the gramma

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Alexander Belopolsky
> But I do have a mathematics background, and I don't remember ever seeing > "for x = value" used in the sense you mean. That's so because in mathematics, "for" is spelled ":" as in {2*a* : *a*∈*Z*} If you can read the above, you should not have trouble reading {2*a* + *b* : *a*∈*Z *: *b = *1

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Alexander Belopolsky
On Thu, May 24, 2018 at 4:59 PM Matt Arcidy wrote: > > > On Thu, May 24, 2018, 11:47 Alexander Belopolsky < > alexander.belopol...@gmail.com> wrote: > >> > But I do have a mathematics background, and I don't remember ever >> seeing >> > "for

Re: [Python-ideas] Let try-except check the exception instance

2018-05-31 Thread Alexander Belopolsky
On Thu, May 31, 2018 at 10:37 AM Nick Coghlan wrote: > > The exception machinery deliberately attempts to avoid instantiating exception objects whenever it can, but that gets significantly more difficult if we always need to create the instance before we can decide whether or not the raised except

Re: [Python-ideas] Add a __cite__ method for scientific packages

2018-07-04 Thread Alexander Belopolsky
On Sun, Jul 1, 2018 at 9:45 AM David Mertz wrote: > .. > There's absolutely nothing in the idea that requires a change in Python, > and Python developers or users are not, as such, the relevant experts. > This is not entirely true. If some variant of __citation__ is endorsed by the community, I

Re: [Python-ideas] Adding optional parameter to shutil.rmtree to not delete root.

2016-08-25 Thread Alexander Belopolsky
> On Aug 25, 2016, at 3:27 PM, Nick Jacobson via Python-ideas > wrote: > > +1 for clear_dir() > > I agree that there's no other obvious meaning that it could have. +1, but I think "cleardir" would better match naming conventions in the shutil module. (My personal rule of thumb on the use