Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread Paul Rubin
Steve D'Aprano writes: > Since it is *optional*, it is only a hint, not a fact. You can tell the > compiler that you believe that n will be an int, but it's not guaranteed. The runtime could check at the entry to the function that n is an int, and then it wouldn't have to keep re-checking on the

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread Steve D'Aprano
On Mon, 17 Apr 2017 05:16 am, bartc wrote: > But it was OK for Steve to 'win' the benchmark by substituting my test > code with something only vaguely related, and much simpler? Okay, you're now being obnoxious, and telling lies about me. What I said was "FOR WHAT IT'S WORTH [emphasis added],

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Steve D'Aprano
On Mon, 17 Apr 2017 05:49 am, Dennis Lee Bieber wrote: > On Mon, 17 Apr 2017 02:48:08 +1000, Steve D'Aprano > declaimed the following: > >>On Sun, 16 Apr 2017 11:57 pm, bartc wrote: >> >>> But people just don't want it. >> >>Damn straight. Now you get it. It's not about how easy it is to impleme

python folder tree for windows 10

2017-04-16 Thread Eb Guenther
I'm having difficulty matching the Python docs suggested folders for Python stuff with where I actually find things (or not find things) Especially for packages. I've got a packages folder in my installation folder, but none in the apps data folder, though the docs point there. Could someone pr

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Gregory Ewing
bartc wrote: > - describing the various syntax forms; > - explaining how they differ; > - tutorials for beginners showing each form; And you don't have to explain how an endless loop should be written as 'while True', meanwhile advising against using 'while 1'? You don't have to mention i

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread bartc
On 16/04/2017 19:42, Chris Angelico wrote: On Mon, Apr 17, 2017 at 4:21 AM, bartc wrote: Here is a function from some old CPython source that appears to be something to do with While statements: static int validate_while(node *tree) { ... Look, no comments! Are you going to castigate the dev

take select request from django from

2017-04-16 Thread Xristos Xristoou
hello i have create a select django form with list of images for per user. How to take that select request in my views.py ? i have success only to create correct that select list but i need take that select request but i dont know how. models.py class MyModel(models.Model): user = models

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread Chris Angelico
On Mon, Apr 17, 2017 at 5:16 AM, bartc wrote: > On 16/04/2017 20:00, Chris Angelico wrote: >> >> On Mon, Apr 17, 2017 at 4:43 AM, bartc wrote: > > >> Sure! If all you care about is winning benchmarks, > > > The benchmarks should be about comparing things. But they have to be like > for like. You

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread bartc
On 16/04/2017 20:00, Chris Angelico wrote: On Mon, Apr 17, 2017 at 4:43 AM, bartc wrote: Sure! If all you care about is winning benchmarks, The benchmarks should be about comparing things. But they have to be like for like. Since this was about the effects of type annotations, it would b

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread Chris Angelico
On Mon, Apr 17, 2017 at 4:43 AM, bartc wrote: >> >> For what it's worth, on my machine (2GB RAM and 1.2GHz CPU) I can add up >> 100 >> million ints in 14 seconds: >> >> py> with Stopwatch(): >> ... sum(range(1)) >> ... >> 49995000 >> time taken: 14.032116 seconds > > > I'm surp

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread bartc
On 16/04/2017 18:13, Steve D'Aprano wrote: On Mon, 17 Apr 2017 02:20 am, justin walters wrote: On Sun, Apr 16, 2017 at 8:46 AM, bartc wrote: What were the results with Python on your machine? Well, at first I tried to implement it with a generator. I gave up on waiting for the program to

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Chris Angelico
On Mon, Apr 17, 2017 at 4:21 AM, bartc wrote: > Here is a function from some old CPython source that appears to be something > to do with While statements: > > static int > validate_while(node *tree) > { > int nch = NCH(tree); > int res = (validate_ntype(tree, while_stmt) >

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread bartc
On 16/04/2017 17:30, Steve D'Aprano wrote: On Sun, 16 Apr 2017 10:06 pm, bartc wrote: (The 30 Loc figure is with support for loops /in general/ already in place, and is for /adding/ a new loop statement, in this case 'while') What part of *testing* and *documenting* do you not understand?

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Steve D'Aprano
On Mon, 17 Apr 2017 03:00 am, Rustom Mody wrote: > BTW I regard Steven's long list of things that youve missed such as > regression tests, docs etc to be somewhat off the mark > To see that try this experiment: > Just add a feature to python that matters to you along with all these > requirements

RE: Namedtuples: some unexpected inconveniences

2017-04-16 Thread Deborah Swanson
Peter Otten wrote, on Saturday, April 15, 2017 12:44 AM > > Deborah Swanson wrote: > > > I know it's your "ugly" answer, but can I ask what the '**' in > > > > fix = {label: max(values, key=len)} > > group[:] = [record._replace(**fix) for record in group] > > > > means? > > d = {"a": 1, "b": 2

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread Steve D'Aprano
On Mon, 17 Apr 2017 02:20 am, justin walters wrote: > On Sun, Apr 16, 2017 at 8:46 AM, bartc wrote: > >> What were the results with Python on your machine? > > > > Well, at first I tried to implement it with a generator. I gave up on > waiting for the program to complete > after about 6 minut

Installing a newly-built python on windows

2017-04-16 Thread joao . moreira . sa . coutinho
Hi all, I've followed the instructions in the 1st chapter (Getting Started) of the Python Developers's Guide to compile python 3.6 from source, using VS 2017 on a Windows 7 SP1. I successfully built 35 of the 40 subprojects, and the python interpreter in cpython\PCbuild\amd64 is working fine.

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Terry Reedy
On 4/16/2017 11:35 AM, Michael Torrie wrote: On 04/16/2017 07:57 AM, bartc wrote: But people just don't want it. /That/ is what surprises me, when people reject things that to me are no-brainers. Whereas to me, it is a no-brainer that we are better off *without* multiple while/loop construct

Installing a newly-built python on windows

2017-04-16 Thread joao . moreira . sa . coutinho
Hi all, I've followed the instructions in the 1st chapter (Getting Started) of the Python Developers's Guide to compile python 3.6 from source, using VS 2017 on a Windows 7 SP1. I successfully built 35 of the 40 subprojects, and the python interpreter in cpython\PCbuild\amd64 is working fine.

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Rustom Mody
On Sunday, April 16, 2017 at 7:27:49 PM UTC+5:30, bartc wrote: > Technically, adding this one feature to Python /is/ trivial, ^ You are not paying attention bart and I am not likely to pursue this beyond this post. I tried to say as are others that the substantive reasons to reject a

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Steve D'Aprano
On Sun, 16 Apr 2017 11:57 pm, bartc wrote: > Yet countless other, far more elaborate features /are/ added all the time. Indeed. Because they are needed. Because they add functionality that Python doesn't already have, or seriously improves the interface to that functionality. > Technically, add

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Steve D'Aprano
On Sun, 16 Apr 2017 10:06 pm, bartc wrote: > On 16/04/2017 03:51, Steve D'Aprano wrote: >> On Sat, 15 Apr 2017 10:17 pm, bartc wrote: > >>> Yes, I'm constantly surprised at this, as such syntax has a very low >>> cost (in my last compiler, supporting 'while' for example only added 30 >>> lines to

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread justin walters
On Sun, Apr 16, 2017 at 8:46 AM, bartc wrote: > What were the results with Python on your machine? Well, at first I tried to implement it with a generator. I gave up on waiting for the program to complete after about 6 minutes. After using your code almost exactly I get: >>> Sum: 1499850

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread bartc
On 16/04/2017 15:22, Chris Angelico wrote: On Sun, Apr 16, 2017 at 11:57 PM, bartc wrote: Technically, adding this one feature to Python /is/ trivial, for example, allowing while: as a synonym for while True:, but preferably using a new keyword such as loop. Nothing else needs to be touched. An

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread bartc
On 16/04/2017 16:00, justin walters wrote: On Sun, Apr 16, 2017 at 3:55 AM, bartc wrote: Example C of the same silly program in Python: def add(a,b): return a+b def testfn(): sum=a=b=0 for i in range(1): sum += add(a,b) a += 1 b += 2 print (a,

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Michael Torrie
On 04/16/2017 07:57 AM, bartc wrote: > But people just don't want it. > > /That/ is what surprises me, when people reject things that to me are > no-brainers. I simply don't care about these missing loop constructs. Python works great for what I use it for, and apparently works well for many pe

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread justin walters
On Sun, Apr 16, 2017 at 3:55 AM, bartc wrote: > Example C of the same silly program in Python: > > def add(a,b): > return a+b > > def testfn(): > sum=a=b=0 > for i in range(1): > sum += add(a,b) > a += 1 > b += 2 > > print (a,b,sum) > > testfn() > >

Re: Python 3.5+ Arrow keys and others in the console

2017-04-16 Thread Vincent Vande Vyvre
Le 16/04/17 à 15:19, Wolfgang Maier a écrit : On 16.04.2017 10:56, Vincent Vande Vyvre wrote: Hi, I'm using Python 3.5 and 3.6 in venv and I see a strange behaviour in the interactive interpreter. The arrow keys can't be used to move the cursor into the current line of code or to rewrite the l

Re: write arrays to disk

2017-04-16 Thread Irmen de Jong
On 16-4-2017 14:28, jorge.conr...@cptec.inpe.br wrote: > Hi, > > I'm new on Python software. I would like to write on disk arrays in binary or > ascii > format. Can someone please help me? > > Thanks, > > Conrado What kind of data is in the arrays? Who or what will be reading the files? And mo

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Chris Angelico
On Sun, Apr 16, 2017 at 11:57 PM, bartc wrote: > Technically, adding this one feature to Python /is/ trivial, for example, > allowing while: as a synonym for while True:, but preferably using a new > keyword such as loop. Nothing else needs to be touched. And it could have > been done right at the

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread bartc
On 16/04/2017 13:22, Rustom Mody wrote: On Sunday, April 16, 2017 at 5:36:28 PM UTC+5:30, bartc wrote: On 16/04/2017 03:51, Steve D'Aprano wrote: On Sat, 15 Apr 2017 10:17 pm, bartc wrote: Yes, I'm constantly surprised at this, as such syntax has a very low cost (in my last compiler, support

Re: Python 3.5+ Arrow keys and others in the console

2017-04-16 Thread Wolfgang Maier
On 16.04.2017 10:56, Vincent Vande Vyvre wrote: Hi, I'm using Python 3.5 and 3.6 in venv and I see a strange behaviour in the interactive interpreter. The arrow keys can't be used to move the cursor into the current line of code or to rewrite the last lines. With the 3.5 I can use the backspac

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread Chris Angelico
On Sun, Apr 16, 2017 at 8:55 PM, bartc wrote: > On 16/04/2017 05:27, Steve D'Aprano wrote: >> >> On Sat, 15 Apr 2017 11:55 am, Rick Johnson wrote: >> >>> apparently, the py-devs believe we >>> only deserve type declarations that do nothing to speed up >>> code execution (aka: type-hints), instead

write arrays to disk

2017-04-16 Thread jorge . conrado
Hi, I'm new on Python software. I would like to write on disk arrays in binary or ascii format. Can someone please help me? Thanks, Conrado -- https://mail.python.org/mailman/listinfo/python-list

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Rustom Mody
On Sunday, April 16, 2017 at 5:36:28 PM UTC+5:30, bartc wrote: > On 16/04/2017 03:51, Steve D'Aprano wrote: > > On Sat, 15 Apr 2017 10:17 pm, bartc wrote: > > >> Yes, I'm constantly surprised at this, as such syntax has a very low > >> cost (in my last compiler, supporting 'while' for example only

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread bartc
On 16/04/2017 03:51, Steve D'Aprano wrote: On Sat, 15 Apr 2017 10:17 pm, bartc wrote: Yes, I'm constantly surprised at this, as such syntax has a very low cost (in my last compiler, supporting 'while' for example only added 30 lines to the project). That's the advantage of writing your own p

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Ben Bacarisse
Steve D'Aprano writes: > I don't remember the language, but I remember seeing one generalisation of > the repeat/do loop that puts the test in the middle, rather than at the > start or end of the loop. If I remember it was something like: > > DO > setup code # executed once only > REPEAT >

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread bartc
On 16/04/2017 05:27, Steve D'Aprano wrote: On Sat, 15 Apr 2017 11:55 am, Rick Johnson wrote: apparently, the py-devs believe we only deserve type declarations that do nothing to speed up code execution (aka: type-hints), instead of type declarations that could actually speed up the code. Go fig

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread alister
On Sun, 16 Apr 2017 09:48:15 +, alister wrote: > On Sun, 16 Apr 2017 14:27:28 +1000, Steve D'Aprano wrote: > >> On Sat, 15 Apr 2017 11:55 am, Rick Johnson wrote: >> >>> apparently, the py-devs believe we only deserve type declarations that >>> do nothing to speed up code execution (aka: type

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread alister
On Sun, 16 Apr 2017 14:27:28 +1000, Steve D'Aprano wrote: > On Sat, 15 Apr 2017 11:55 am, Rick Johnson wrote: > >> apparently, the py-devs believe we only deserve type declarations that >> do nothing to speed up code execution (aka: type-hints), instead of >> type declarations that could actually

Re: "Goto" statement in Python

2017-04-16 Thread Chris Angelico
On Sun, Apr 16, 2017 at 5:21 PM, Mikhail V wrote: > I am in the category "I just want to express some > algorithm and don't want to learn every year new concepts". > I tend to think that extremely restricted syntax, in the sence > of having only few flow control instructions actually helps with >

Python 3.5+ Arrow keys and others in the console

2017-04-16 Thread Vincent Vande Vyvre
Hi, I'm using Python 3.5 and 3.6 in venv and I see a strange behaviour in the interactive interpreter. The arrow keys can't be used to move the cursor into the current line of code or to rewrite the last lines. With the 3.5 I can use the backspace and erase the code but not in 3.6 Python 3

Re: "Goto" statement in Python

2017-04-16 Thread Mikhail V
On 14 April 2017 at 03:44, Steve D'Aprano wrote: > On Fri, 14 Apr 2017 12:52 am, bartc wrote: > >> I know this isn't the Python need-for-speed thread, but this is a >> classic example where the lack of one simple feature leads to using >> slower, more cumbersome ones. > > Dear gods, have I fallen