Re: Python is not bad ;-)

2015-05-02 Thread Mark Lawrence
On 02/05/2015 14:50, Joonas Liik wrote: [top posting fixed] On 2 May 2015 at 14:42, Marko Rauhamaa wrote: Christian Gollwitzer : That's why I still think it is a microoptimization, which helps only in some specific cases. It isn't done for performance. It's done to avoid a stack overflo

Re: Python is not bad ;-)

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 9:53 AM, Joonas Liik wrote: Top-posting is heavily frowned at on this list, so please don't do it. > Balancing of trees is kind of irrelevant when "tree" means "search space" > no? I think it's relatively rare that DFS is truly the best algorithm for such a search. For on

Re: Python is not bad ;-)

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 9:55 AM, Chris Angelico wrote: > On Sun, May 3, 2015 at 1:45 AM, Ian Kelly wrote: >> On Sat, May 2, 2015 at 5:42 AM, Marko Rauhamaa wrote: >>> Christian Gollwitzer : >>> That's why I still think it is a microoptimization, which helps only in some specific cases.

Re: Python is not bad ;-)

2015-05-02 Thread Joonas Liik
Balancing of trees is kind of irrelevant when "tree" means "search space" no? And you definitely dont need to keep the entire tree in memory at the same time. By cropping unsuitable branches early (and not keeping the entire tree in memory) it is quite easy to have more than 1000 of call stack and

Re: Python is not bad ;-)

2015-05-02 Thread Joonas Liik
I agree, stack overflow is literally the main issue that ive run in to (tree traversal) I've yet to refactor recursion to iterative for speed, but i have done so to avoid hitting the stack size limit. Tree traversal and similar problems in particular lend themselves well to recursion and are not q

Re: Python is not bad ;-)

2015-05-02 Thread Chris Angelico
On Sun, May 3, 2015 at 1:45 AM, Ian Kelly wrote: > On Sat, May 2, 2015 at 5:42 AM, Marko Rauhamaa wrote: >> Christian Gollwitzer : >> >>> That's why I still think it is a microoptimization, which helps only >>> in some specific cases. >> >> It isn't done for performance. It's done to avoid a stac

Re: Python is not bad ;-)

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 5:42 AM, Marko Rauhamaa wrote: > Christian Gollwitzer : > >> That's why I still think it is a microoptimization, which helps only >> in some specific cases. > > It isn't done for performance. It's done to avoid a stack overflow > exception. If your tree is balanced, then th

Re: Python is not bad ;-)

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 4:35 AM, Dave Angel wrote: > I can't see how that is worth doing. The recursive version is already a > distortion of the definition of factorial that I learned. And to force it > to be recursive and also contort it so it does the operations in the same > order as the iterat

Re: Python is not bad ;-)

2015-05-02 Thread Marko Rauhamaa
Christian Gollwitzer : > That's why I still think it is a microoptimization, which helps only > in some specific cases. It isn't done for performance. It's done to avoid a stack overflow exception. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is not bad ;-)

2015-05-02 Thread Cecil Westerhof
Op Saturday 2 May 2015 12:35 CEST schreef Dave Angel: > On 05/02/2015 05:33 AM, Cecil Westerhof wrote: > > Please check your email settings. Your messages that you type seem > to be indented properly, but those that are quoting earlier messages > (even your own) are not. See below. I suspect there

Re: Python is not bad ;-)

2015-05-02 Thread Christian Gollwitzer
Am 02.05.15 um 13:21 schrieb Chris Angelico: On Sat, May 2, 2015 at 9:07 PM, Christian Gollwitzer wrote: I need to add, I grew up with imperative programming, and as such got recursion as the solution to problems that are too complex for iteration, i.e. tree traversal and such, and exactly thes

Re: Python is not bad ;-)

2015-05-02 Thread Chris Angelico
On Sat, May 2, 2015 at 9:07 PM, Christian Gollwitzer wrote: > I need to add, I grew up with imperative programming, and as such got > recursion as the solution to problems that are too complex for iteration, > i.e. tree traversal and such, and exactly these are never tail-recursive. Tree traversa

Re: Python is not bad ;-)

2015-05-02 Thread Cecil Westerhof
Op Saturday 2 May 2015 11:10 CEST schreef Marko Rauhamaa: > Cecil Westerhof : >> I find factorial a lot cleaner code as factorial_iterative, so here >> tail recursion would be beneficial. > > I would just call math.factorial() and be done with it. You missed the point. I did not need a factorial

Re: Python is not bad ;-)

2015-05-02 Thread Christian Gollwitzer
Am 02.05.15 um 11:58 schrieb Marko Rauhamaa: Chris Angelico : Guido is against anything that disrupts tracebacks, and optimizing tail recursion while maintaining traceback integrity is rather harder. Tail recursion could be suppressed during debugging. Optimized code can play all kinds of non

Re: Python is not bad ;-)

2015-05-02 Thread Chris Angelico
On Sat, May 2, 2015 at 8:22 PM, Dave Angel wrote: > On 05/02/2015 05:58 AM, Marko Rauhamaa wrote: >> >> Chris Angelico : >> >>> Guido is against anything that disrupts tracebacks, and optimizing >>> tail recursion while maintaining traceback integrity is rather harder. >> >> >> Tail recursion coul

Re: Python is not bad ;-)

2015-05-02 Thread Dave Angel
On 05/02/2015 05:33 AM, Cecil Westerhof wrote: Please check your email settings. Your messages that you type seem to be indented properly, but those that are quoting earlier messages (even your own) are not. See below. I suspect there's some problem with how your email program processes htm

Re: Python is not bad ;-)

2015-05-02 Thread Dave Angel
On 05/02/2015 05:58 AM, Marko Rauhamaa wrote: Chris Angelico : Guido is against anything that disrupts tracebacks, and optimizing tail recursion while maintaining traceback integrity is rather harder. Tail recursion could be suppressed during debugging. Optimized code can play all kinds of no

Re: Python is not bad ;-)

2015-05-02 Thread Cecil Westerhof
Op Saturday 2 May 2015 10:26 CEST schreef Cecil Westerhof: > Op Friday 1 May 2015 09:03 CEST schreef Steven D'Aprano: > >> On Thu, 30 Apr 2015 09:30 pm, Cecil Westerhof wrote: >> >>> Tail recursion would nice to have also. >> >> People coming from functional languages like Lisp and Haskell often >

Re: Python is not bad ;-)

2015-05-02 Thread Marko Rauhamaa
Chris Angelico : > Guido is against anything that disrupts tracebacks, and optimizing > tail recursion while maintaining traceback integrity is rather harder. Tail recursion could be suppressed during debugging. Optimized code can play all kinds of non-obvious tricks with the execution frame. >

Re: Python is not bad ;-)

2015-05-02 Thread Chris Angelico
On Sat, May 2, 2015 at 7:10 PM, Marko Rauhamaa wrote: > Note: Scheme is my favorite language and I use tail recursion all the > time. I also think eliminating tail recursion is such a low-hanging > fruit that even CPython should just pick it. However, I wouldn't use the > fibonacci sequence to jus

Re: Python is not bad ;-)

2015-05-02 Thread Marko Rauhamaa
Cecil Westerhof : > I find factorial a lot cleaner code as factorial_iterative, so here > tail recursion would be beneficial. I would just call math.factorial() and be done with it. Note: Scheme is my favorite language and I use tail recursion all the time. I also think eliminating tail recursion

Re: Python is not bad ;-)

2015-05-02 Thread Cecil Westerhof
Op Friday 1 May 2015 09:03 CEST schreef Steven D'Aprano: > On Thu, 30 Apr 2015 09:30 pm, Cecil Westerhof wrote: > >> Tail recursion would nice to have also. > > People coming from functional languages like Lisp and Haskell often > say that, but how many recursive algorithms naturally take a > tail

Re: Python is not bad ;-)

2015-05-02 Thread Gregory Ewing
Steven D'Aprano wrote: People coming from functional languages like Lisp and Haskell often say that, but how many recursive algorithms naturally take a tail-call form? Not that many. And the ones that do tend to be the ones that are better expressed iteratively in Python. So Python doesn't rea

Re: Python is not bad ;-)

2015-05-01 Thread Christian Gollwitzer
Am 01.05.15 um 09:03 schrieb Steven D'Aprano: On Thu, 30 Apr 2015 09:30 pm, Cecil Westerhof wrote: Tail recursion would nice to have also. People coming from functional languages like Lisp and Haskell often say that, but how many recursive algorithms naturally take a tail-call form? Not that

Re: Python is not bad ;-)

2015-05-01 Thread Cecil Westerhof
Op Friday 1 May 2015 09:03 CEST schreef Steven D'Aprano: > On Thu, 30 Apr 2015 09:30 pm, Cecil Westerhof wrote: > >> Tail recursion would nice to have also. > > People coming from functional languages like Lisp and Haskell often > say that, but how many recursive algorithms naturally take a > tail

Re: Python is not bad ;-)

2015-05-01 Thread Steven D'Aprano
On Thu, 30 Apr 2015 09:30 pm, Cecil Westerhof wrote: > Tail recursion would nice to have also. People coming from functional languages like Lisp and Haskell often say that, but how many recursive algorithms naturally take a tail-call form? Not that many. I suppose that it would be nice if Python

Re: Python is not bad ;-)

2015-04-30 Thread Steven D'Aprano
On Thu, 30 Apr 2015 08:16 pm, Marko Rauhamaa wrote: > Still, Python has features that defy effective optimization. Most > notably, Python's dot notation translates into a hash table lookup -- or > worse. Effective optimization may be difficult, but it isn't impossible. PyPy has a very effective

Re: Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 19:59 CEST schreef Christian Gollwitzer: > Am 30.04.15 um 18:11 schrieb Cecil Westerhof: >> Op Thursday 30 Apr 2015 16:03 CEST schreef Michael Torrie: >> >>> On 04/30/2015 01:07 AM, Cecil Westerhof wrote: When I do that the computer is freezed a few times. That is a >>

Re: Python is not bad ;-)

2015-04-30 Thread Christian Gollwitzer
Am 30.04.15 um 18:11 schrieb Cecil Westerhof: Op Thursday 30 Apr 2015 16:03 CEST schreef Michael Torrie: On 04/30/2015 01:07 AM, Cecil Westerhof wrote: When I do that the computer is freezed a few times. That is a little less nice. Does not happen with Clojure when it gets an out of memory.

Re: Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 16:03 CEST schreef Michael Torrie: > On 04/30/2015 01:07 AM, Cecil Westerhof wrote: >> When I do that the computer is freezed a few times. That is a >> little less nice. Does not happen with Clojure when it gets an out >> of memory. > > A system freeze is probably due to th

Re: Python is not bad ;-)

2015-04-30 Thread Michael Torrie
On 04/30/2015 01:07 AM, Cecil Westerhof wrote: > When I do that the computer is freezed a few times. That is a little > less nice. Does not happen with Clojure when it gets an out of memory. A system freeze is probably due to thrashing by your operating system as a process (in this case Python) us

Re: Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 12:16 CEST schreef Marko Rauhamaa: > Ben Finney : > >> The latter is not a property of Python; a programming language >> doesn't have runtime performance. Rather, runtime performance is a >> property of some specific *implementation* — that is, the runtime >> Python machine

Re: Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 11:10 CEST schreef Ben Finney: >> I like it that the code is concise and clear. But also that the >> performance is not bad. > > The former is a property of Python, which is a programming language. > I agree with your assessment :-) > > The latter is not a property of Pytho

Re: Python is not bad ;-)

2015-04-30 Thread Chris Angelico
On Thu, Apr 30, 2015 at 8:16 PM, Marko Rauhamaa wrote: > Ben Finney : > >> The latter is not a property of Python; a programming language doesn't >> have runtime performance. Rather, runtime performance is a property of >> some specific *implementation* — that is, the runtime Python machine. >> >>

Re: Python is not bad ;-)

2015-04-30 Thread Marko Rauhamaa
Ben Finney : > The latter is not a property of Python; a programming language doesn't > have runtime performance. Rather, runtime performance is a property of > some specific *implementation* — that is, the runtime Python machine. > > There are numerous Python runtimes, and they have different > p

Re: Python is not bad ;-)

2015-04-30 Thread Ben Finney
Cecil Westerhof writes: > I am coding with Python again. Great to know! > I like it that the code is concise and clear. But also that the > performance is not bad. The former is a property of Python, which is a programming language. I agree with your assessment :-) The latter is not a propert