Re: Goto Considered Harmful [was Re: Python and the need for speed]

2017-04-14 Thread Gregory Ewing
Steve D'Aprano wrote: If PIC is so great, why do no other languages have it? Something akin to it has turned up in other places, although usually in the guise of an output formatting facility rather than a way of describing how data is stored internally. For example, the PRINT USING found in s

Re: Goto Considered Harmful [was Re: Python and the need for speed]

2017-04-14 Thread Gregory Ewing
Ian Kelly wrote: Yikes. I never took the time to learn COBOL, but that almost sounds like something that you'd find in an esoteric language like INTERCAL. COBOL has other fun stuff like that, too. For example, the destination of a GOTO statement can be changed from elsewhere in the program: ht

Re: Goto Considered Harmful [was Re: Python and the need for speed]

2017-04-14 Thread Marko Rauhamaa
Gregory Ewing : > Steve D'Aprano wrote: > >> If PIC is so great, why do no other languages have it? > > Something akin to it has turned up in other places, although usually > in the guise of an output formatting facility rather than a way of > describing how data is stored internally. For example,

Re: Python and the need for speed

2017-04-14 Thread Marko Rauhamaa
Christian Gollwitzer : > Am 13.04.17 um 15:20 schrieb Marko Rauhamaa: >> >> Not sure if this is still valid: >> >>Still today Flash RAM cells built in SSDs have a limited lifespan. >>Every write (not read) cycle or better every erasure wears a memory >>cell and at some time it will sto

Re: "Goto" statement in Python

2017-04-14 Thread bartc
On 14/04/2017 02: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 back in time to 19

Re: Python and the need for speed

2017-04-14 Thread bartc
On 14/04/2017 03:13, Steve D'Aprano wrote: On Wed, 12 Apr 2017 07:56 pm, bart4...@gmail.com wrote: if you care most about program correctness, type-safety and correctness proofs, choosing C is probably the wrong decision. CPython is written in C; bad choice? (** Although I find code full o

Re: Python and the need for speed

2017-04-14 Thread Chris Angelico
On Fri, Apr 14, 2017 at 8:42 PM, bartc wrote: >> Classes and decorators are not esoteric. You sound like an old man who >> complains about this new-fangled "telephone", and how things were so much >> better when we had messenger boys to deliver messages anywhere in the >> city. > > > These days I

Re: Python and the need for speed

2017-04-14 Thread bartc
On 14/04/2017 11:56, Chris Angelico wrote: On Fri, Apr 14, 2017 at 8:42 PM, bartc wrote: Classes and decorators are not esoteric. You sound like an old man who complains about this new-fangled "telephone", and how things were so much better when we had messenger boys to deliver messages anywher

Re: Python and the need for speed

2017-04-14 Thread Chris Angelico
On Fri, Apr 14, 2017 at 10:04 PM, bartc wrote: > >> Of course, if you feel the other way, you're most welcome to write >> everything in C. > > > 'pseudo-code' is often the language used to describe an algorithm in terms > that are independent of any particular language. It doesn't usually contain

Re: Python Command Line Arguments

2017-04-14 Thread Bernd Nawothnig
On 2017-04-13, Jason Friedman wrote: >> I have this code which I got from https://www.tutorialspoint. >> com/python/python_command_line_arguments.htm The example works fine but >> when I modify it to what I need, it only half works. The problem is the >> try/except. If you don't specify an input/ou

Re: "Goto" statement in Python

2017-04-14 Thread Bernd Nawothnig
On 2017-04-13, Mikhail V wrote: > On 13 April 2017 at 18:48, Ian Kelly wrote: >> On Thu, Apr 13, 2017 at 10:23 AM, Mikhail V wrote: >>> Now I wonder, have we already collected *all* bells and whistles of Python >>> in these two examples, or is there something else for expressing trivial >>> thin

Re: "Goto" statement in Python

2017-04-14 Thread Bernd Nawothnig
On 2017-04-13, Grant Edwards wrote: > On 2017-04-13, Rob Gaddi wrote: > >> No, C doesn't support exception handling. As a result, handling error >> conditions in C is a huge pain for which (forward-only) goto is often, >> while not the only remedy, the least painful one. > > Indeed. That is alm

Re: "Goto" statement in Python

2017-04-14 Thread Chris Green
Bernd Nawothnig wrote: > On 2017-04-13, Mikhail V wrote: > > On 13 April 2017 at 18:48, Ian Kelly wrote: > >> On Thu, Apr 13, 2017 at 10:23 AM, Mikhail V wrote: > >>> Now I wonder, have we already collected *all* bells and whistles of Python > >>> in these two examples, or is there something els

Re: "Goto" statement in Python

2017-04-14 Thread Chris Angelico
On Sat, Apr 15, 2017 at 12:13 AM, Dennis Lee Bieber wrote: > On Thu, 13 Apr 2017 18:36:57 -0600, Ian Kelly > declaimed the following: > >> >>Well, you can do it in Assembly. And BASIC, if you count the primitive >>GOSUB-type subroutines, though modern BASICs have real subroutines >>that don't all

Hi! i need some help with a program in python on Raspberry pi3.

2017-04-14 Thread Kasper
every time i run the program i get this messeage: Traceback (most recent call last): File "smartmirror.py", line 159, in get_weather temprature2 = "%S%S" % (str(int(weather_obj['currently']['temperature'])), degree_sign) KeyError: 'currently' Error: 'currently'. Cannot get weather. How do i

Re: Hi! i need some help with a program in python on Raspberry pi3.

2017-04-14 Thread Steve D'Aprano
On Sat, 15 Apr 2017 12:27 am, Kasper wrote: > every time i run the program i get this messeage: > > Traceback (most recent call last): > File "smartmirror.py", line 159, in get_weather > temprature2 = "%S%S" % > (str(int(weather_obj['currently']['temperature'])), > degree_sign) > KeyErr

Regular Expressions, Speed, Python, and NFA

2017-04-14 Thread Malik Rumi
I am running some tests using the site regex101 to figure out the correct regexs to use for a project. I was surprised at how slow it was, constantly needing to increase the timeouts. I went Googling for a reason, and solution, and found Russ Cox’s article from 2007: https://swtch.com/~rsc/rege

Re: Regular Expressions, Speed, Python, and NFA

2017-04-14 Thread Steve D'Aprano
On Sat, 15 Apr 2017 01:12 am, Malik Rumi wrote: > I couldn’t understand why, if this was even remotely correct, > we don’t use NFA in Python [...] > I don’t think I’m qualified to take on the idea of creating > a new NFA module for Python. If not you, then who should do it? Python is open so

Re: Hi! i need some help with a program in python on Raspberry pi3.

2017-04-14 Thread Peter Otten
Kasper wrote: > every time i run the program i get this messeage: > > Traceback (most recent call last): > File "smartmirror.py", line 159, in get_weather > temprature2 = "%S%S" % (str(int(weather_obj['currently'] ['temperature'])), > degree_sign) > KeyError: 'currently' > Error: 'currently

RE: Regular Expressions, Speed, Python, and NFA

2017-04-14 Thread Joseph L. Casale
-Original Message- From: Python-list [mailto:python-list- bounces+jcasale=activenetwerx@python.org] On Behalf Of Malik Rumi Sent: Friday, April 14, 2017 9:12 AM To: python-list@python.org Subject: Regular Expressions, Speed, Python, and NFA > I am running some tests using the site rege

Re: Regular Expressions, Speed, Python, and NFA

2017-04-14 Thread Peter Otten
Malik Rumi wrote: > I am running some tests using the site regex101 to figure out the correct > regexs to use for a project. I was surprised at how slow it was, > constantly needing to increase the timeouts. I went Googling for a reason, > and solution, and found Russ Cox’s article from 2007: > ht

Re: "Goto" statement in Python

2017-04-14 Thread Rob Gaddi
On 04/14/2017 07:19 AM, Dennis Lee Bieber wrote: On Fri, 14 Apr 2017 11:44:59 +1000, Steve D'Aprano declaimed the following: Even that's not enough for some. Donald Knuth, who supports the use of GOTO under some circumstances, maintains that any program using GOTOs should have the invariant t

Re: Regular Expressions, Speed, Python, and NFA

2017-04-14 Thread Rob Gaddi
On 04/14/2017 08:12 AM, Malik Rumi wrote: I am running some tests using the site regex101 to figure out the correct regexs to use for a project. I was surprised at how slow it was, constantly needing to increase the timeouts. I went Googling for a reason, and solution, and found Russ Cox’s art

Re: Python and the need for speed

2017-04-14 Thread rurpy--- via Python-list
On 04/13/2017 08:13 PM, Steve D'Aprano wrote: > On Wed, 12 Apr 2017 07:56 pm, bart4...@gmail.com wrote: > [...] >> (** Although I find code full of class definitions, one-liners, decorators >> and all the other esoterics, incomprehensive. I'm sure I'm not the only >> one, so perhaps readability isn

Re: Hi! i need some help with a program in python on Raspberry pi3.

2017-04-14 Thread Terry Reedy
On 4/14/2017 10:27 AM, Kasper wrote: every time i run the program i get this messeage: Traceback (most recent call last): File "smartmirror.py", line 159, in get_weather temprature2 = "%S%S" % (str(int(weather_obj['currently']['temperature'])), degree_sign) KeyError: 'currently' Error: 'cu

RE: Namedtuples: some unexpected inconveniences

2017-04-14 Thread Deborah Swanson
Peter, Retracing my steps to rewrite the getattr(row, label) code, this is what sent me down the rabbit hole in the first place. (I changed your 'rows' to 'records' just to use the same name everywhere, but all else is the same as you gave me.) I'd like you to look at it and see if you still think

Python3 C extension how to support dir()

2017-04-14 Thread Barry Scott
I have an python3 C++ extension that works. But dir(obj) does not return the list of member variables. How should I support dir() from the C API? I cannot use tp_members, not appropiate to the code I'm writing. If I provide __dir__ I then hit the problem I need the C API version all_attr

Re: Goto Considered Harmful [was Re: Python and the need for speed]

2017-04-14 Thread Marko Rauhamaa
r...@zedat.fu-berlin.de (Stefan Ram): > struct example > { PIC<5,X<15>> last_name; > PIC<88,VALUE<1,3,5,7,9>> odd_numbers; } > > . The above assumes appropriate definitions for »VALUE« (as a > variadic template) »PIC«, and »X«. Only a C++ expert would be able > to provide thes

RE: Namedtuples: some unexpected inconveniences

2017-04-14 Thread Peter Otten
Deborah Swanson wrote: > Peter, > > Retracing my steps to rewrite the getattr(row, label) code, this is what > sent me down the rabbit hole in the first place. (I changed your 'rows' > to 'records' just to use the same name everywhere, but all else is the > same as you gave me.) I'd like you to l

Re: Namedtuples: some unexpected inconveniences

2017-04-14 Thread MRAB
On 2017-04-14 20:34, Deborah Swanson wrote: Peter, Retracing my steps to rewrite the getattr(row, label) code, this is what sent me down the rabbit hole in the first place. (I changed your 'rows' to 'records' just to use the same name everywhere, but all else is the same as you gave me.) I'd lik

Re: Python and the need for speed

2017-04-14 Thread Paul Rubin
bartc writes: > I do know that if I want to port some program (be it in Python or > C++), or simply try and understand it, if I see it's full of class > definitions or whatever, then I won't bother. There was a time in the evolution of OOP when inheritance was thought of as a cool and enabling th

Re: Python and the need for speed

2017-04-14 Thread Rick Johnson
On Wednesday, April 12, 2017 at 1:48:57 AM UTC-5, Steven D'Aprano wrote: > On Tue, 11 Apr 2017 21:10:56 -0700, Rick Johnson wrote: > > > high level languages like Python should make it difficult, > > if not impossible, to write sub- optimal code (at least in > > the blatantly obvious cases). > > Yo

Re: Python and the need for speed

2017-04-14 Thread Rick Johnson
On Wednesday, April 12, 2017 at 4:30:16 AM UTC-5, alister wrote: > On Tue, 11 Apr 2017 16:31:16 -0700, Rick Johnson wrote: > > On Tuesday, April 11, 2017 at 9:56:45 AM UTC-5, Steve D'Aprano wrote: > >> On Tue, 11 Apr 2017 07:56 pm, Brecht Machiels wrote: > >> > On 2017-04-11 08:19:31 +, Steven

RE: Namedtuples: some unexpected inconveniences

2017-04-14 Thread Deborah Swanson
fix = {label: max(values, key=len)} group[:] = [record._replace(**fix) for record in group] Peter Otten wrote, on Friday, April 14, 2017 2:16 PM > > def complete(group, label): > > values = {row[label] for row in group} > > # get "TypeError: tuple indices must be integers, not str" > > Ye

RE: Namedtuples: some unexpected inconveniences

2017-04-14 Thread Deborah Swanson
MRAB wrote, on Friday, April 14, 2017 2:19 PM > > In the line: > > values = {row[label] for row in group} > > 'group' is a list of records; row is a record (namedtuple). > > You can get the members of a namedtuple (also 'normal' tuple) by numeric > index, e.g. row[0], but the point of a n

Re: Python and the need for speed

2017-04-14 Thread Rick Johnson
On Wednesday, April 12, 2017 at 4:34:00 AM UTC-5, Brecht Machiels wrote: > On 2017-04-11 14:56:33 +, Steve D'Aprano said: > > On Tue, 11 Apr 2017 07:56 pm, Brecht Machiels wrote: > [...] > However, we don't really know how Python's performance is > affecting its popularity. It would be good to

Re: Python and the need for speed

2017-04-14 Thread bartc
On 15/04/2017 00:40, Rick Johnson wrote: On Wednesday, April 12, 2017 at 1:48:57 AM UTC-5, Steven D'Aprano wrote: answer = 0 for i in range(10): answer += 1 instead of answer = 10 So... how exactly does the compiler prohibit stupid code? Easy. The same way _any_ optimi

RE: Namedtuples: some unexpected inconveniences

2017-04-14 Thread Deborah Swanson
Gregory Ewing wrote, on Thursday, April 13, 2017 12:17 AM > > Deborah Swanson wrote: > > But I think you got it right in your last sentence below. defaultdict > > copied them because they were immutable, > > No, definitely not. A defaultdict will never take it upon > itself to copy an object yo

Re: Namedtuples: some unexpected inconveniences

2017-04-14 Thread Gregory Ewing
Peter Otten wrote: PS: Personally I would probably take the opposite direction and use dicts throughout... Yes, my suggestion to used namedtuples in the first place was based on the assumption that you would mostly be referring to fields using fixed names. If that's not true, then using namedt

RE: Namedtuples: some unexpected inconveniences

2017-04-14 Thread Deborah Swanson
Roel Schroeven wrote, on Thursday, April 13, 2017 5:26 PM > > Gregory Ewing schreef op 13/04/2017 9:34: > > Deborah Swanson wrote: > >> Peter Otten wrote, on Wednesday, April 12, 2017 1:45 PM > >> > >>> Personally I would immediately discard the header row > once and for > >>> all, not again and

Re: Goto Considered Harmful [was Re: Python and the need for speed]

2017-04-14 Thread Gregory Ewing
Dennis Lee Bieber wrote: And since the original COBOL standard numeric format was BCD, PIC not only defined output layout, but also internal storage needed by numerics and string data types. Unless you said USAGE IS COMPUTATIONAL, which left the compiler free to pick a more efficient st

Re: Python and the need for speed

2017-04-14 Thread Rick Johnson
On Wednesday, April 12, 2017 at 4:57:10 AM UTC-5, bart...@gmail.com wrote: > On Wednesday, 12 April 2017 07:48:57 UTC+1, Steven D'Aprano wrote: > > On Tue, 11 Apr 2017 21:10:56 -0700, Rick Johnson wrote: > > > > > > high level languages like Python should make it > > > difficult, if not impossible

Re: Python and the need for speed

2017-04-14 Thread Rick Johnson
On Wednesday, April 12, 2017 at 8:44:30 AM UTC-5, bart...@gmail.com wrote: > On Wednesday, 12 April 2017 12:56:32 UTC+1, Jussi Piitulainen wrote: > > bartc writes: > > > > > > These are straightforward language enhancements. > > > > FYI, the question is not how to optimize the code but how > > to

Re: Python and the need for speed

2017-04-14 Thread Rick Johnson
On Thursday, April 13, 2017 at 1:32:29 AM UTC-5, Gregory Ewing wrote: > Jussi Piitulainen wrote: > > Traceback (most recent call last): > > File "/dev/fd/63", line 37, in > > SanityClauseException: code is blatantly sub-optimal > > > > As far as I know, no language does that. Because reasons? >

Re: Python and the need for speed

2017-04-14 Thread Rick Johnson
On Thursday, April 13, 2017 at 1:32:28 AM UTC-5, Steven D'Aprano wrote: > On Wed, 12 Apr 2017 14:38:52 +0100, Ben Bacarisse wrote: > > Steve D'Aprano writes: > >> On Wed, 12 Apr 2017 03:39 am, Paul Rubin wrote: > > [...] Indeed, and this is a very common phenomenon: > features which "ordinary" prog

Re: Swiss Ephemeris

2017-04-14 Thread Rick Johnson
On Thursday, April 13, 2017 at 7:39:38 AM UTC-5, Rustom Mody wrote: > Quote from Peter Landin, one of the precursors of modern > functional programming: Most papers in computer science > describe how their author learned what someone else already > knew [And this dates from 60s/70s] Applies beyo