Re: Lucky numbers in Python

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 04:55 CEST schreef Ian Kelly: > On Wed, Apr 29, 2015 at 6:01 PM, Cecil Westerhof wrote: >> Op Thursday 30 Apr 2015 00:38 CEST schreef Ian Kelly: >>> In that case you can definitely omit the middle term of the slice, >>> which will be both more concise and clearer in intent

Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
I am coding with Python again. I like it that the code is concise and clear. But also that the performance is not bad. I wrote Lucky Numbers in Clojure and Python. When calling with 1E7 Clojure takes 12 seconds and Python 8 seconds. When calling it with 1E8 Clojure takes all 4/8 cores and gets an

Re: seek operation in python

2015-04-30 Thread Chris Angelico
On Thu, Apr 30, 2015 at 4:27 PM, Cecil Westerhof wrote: >> with open("input.cpp") as f: >> lines = f.readlines() >> print(lines[7]) > > Is the following not better: > print(open('input.cpp', 'r').readlines()[7]) > > Time is the same (about 25 seconds for 100.000 calls), but I find this > more

Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): """ Get index message from a file, where 0 gets the first message """ return open(expanduser(message_filename), 'r').readlines()[index].rstrip() What is more th

Re: Let exception fire or return None

2015-04-30 Thread Dave Angel
On 04/30/2015 03:43 AM, Cecil Westerhof wrote: I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): """ Get index message from a file, where 0 gets the first message """ return open(expanduser(message_filenam

Re: seek operation in python

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 09:33 CEST schreef Chris Angelico: > On Thu, Apr 30, 2015 at 4:27 PM, Cecil Westerhof wrote: >>> with open("input.cpp") as f: >>> lines = f.readlines() >>> print(lines[7]) >> >> Is the following not better: >> print(open('input.cpp', 'r').readlines()[7]) >> >> Time is the

Re: seek operation in python

2015-04-30 Thread Dave Angel
On 04/30/2015 04:06 AM, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 09:33 CEST schreef Chris Angelico: On Thu, Apr 30, 2015 at 4:27 PM, Cecil Westerhof wrote: with open("input.cpp") as f: lines = f.readlines() print(lines[7]) Is the following not better: print(open('input.cpp', 'r').read

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

Re: Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 10:18 CEST schreef Dave Angel: > On 04/30/2015 03:43 AM, Cecil Westerhof wrote: >> I have a function to fetch a message from a file: >> def get_indexed_message(message_filename, index): >> """ >> Get index message from a file, where 0 gets the first message >> """ >> >> ret

Re: seek operation in python

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 10:31 CEST schreef Dave Angel: > On 04/30/2015 04:06 AM, Cecil Westerhof wrote: >> Op Thursday 30 Apr 2015 09:33 CEST schreef Chris Angelico: >> >>> On Thu, Apr 30, 2015 at 4:27 PM, Cecil Westerhof wrote: > with open("input.cpp") as f: > lines = f.readlines() >

Re: Let exception fire or return None

2015-04-30 Thread Peter Otten
Cecil Westerhof wrote: > I have a function to fetch a message from a file: > def get_indexed_message(message_filename, index): > """ > Get index message from a file, where 0 gets the first message > """ > > return open(expanduser(message_filename), > 'r

Re: seek operation in python

2015-04-30 Thread Chris Angelico
On Thu, Apr 30, 2015 at 7:06 PM, Cecil Westerhof wrote: > I already done it. I thought it not to much work. And it even makes > some code shorter: > -marshal_file= open(expanduser(marshal_filename), 'r') > -not_list= load(marshal_file) > -marshal_file.close() > -return

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 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 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: Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 11:30 CEST schreef Peter Otten: > Cecil Westerhof wrote: > >> I have a function to fetch a message from a file: >> def get_indexed_message(message_filename, index): >> """ >> Get index message from a file, where 0 gets the first message >> """ >> >> return open(expanduser(m

Let me introduce myself.

2015-04-30 Thread Luca Menegotto
Hello everybody. One of the common rules i like most is: when you enter in a community, introduce yourself! So here I am! Luca, old developer (50 and still running!), Python (and not only) developer, from Marostica, a lovely small town in the north-eastern part of Italy. It's a pleasure fo

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: Let me introduce myself.

2015-04-30 Thread Tim Golden
On 30/04/2015 12:48, Luca Menegotto wrote: > Hello everybody. Hi Luca, > > One of the common rules i like most is: when you enter in a community, > introduce yourself! In fact, many people don't on this list, so it's nice of you to offer us this courtesy :) > > So here I am! Luca, old develop

Re: Let exception fire or return None

2015-04-30 Thread Thomas 'PointedEars' Lahn
Cecil Westerhof wrote: > I have a function to fetch a message from a file: > def get_indexed_message(message_filename, index): > """ > Get index message from a file, where 0 gets the first message > """ > > return open(expanduser(message_filename), > 'r

Re: Let exception fire or return None

2015-04-30 Thread Peter Otten
Cecil Westerhof wrote: >> (2) you may want to take measures to limit memory usage, e. g. >> >> assert index >= 0 > > I put that in, but as first statement. For the record, this was not a recommended check, but rather a way to communicate to the reader of my code that unlike yours it doesn't sup

Re: Let exception fire or return None

2015-04-30 Thread Antoon Pardon
Op 30-04-15 om 09:43 schreef Cecil Westerhof: > I have a function to fetch a message from a file: > def get_indexed_message(message_filename, index): > """ > Get index message from a file, where 0 gets the first message > """ > > return open(expanduser(message_f

Re: Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 13:26 CEST schreef Cecil Westerhof: >> try: >> [line] = itertools.islice(f, index, index+1) >> except ValueError: >> raise IndexError >> return line.rstrip() > > In my case it is not important. (The biggest file I use has between > 100 and 200 lines), but I publish it, so I

Re: seek operation in python

2015-04-30 Thread Cecil Westerhof
Op Wednesday 29 Apr 2015 20:08 CEST schreef siva sankari R.: > file=open("input","r") > line=file.seek(7) > print line > > The above code is supposed to print a line but it prints "none". I > don't know where the mistake is. Help.! You could use my module: https://github.com/CecilWesterhof/P

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: Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 14:28 CEST schreef Peter Otten: > Cecil Westerhof wrote: > >>> (2) you may want to take measures to limit memory usage, e. g. >>> >>> assert index >= 0 >> >> I put that in, but as first statement. > > For the record, this was not a recommended check, but rather a way > to c

Re: Not possible to hide local variables

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 14:53 CEST schreef Dennis Lee Bieber: > On Wed, 29 Apr 2015 22:31:13 -0400, Dave Angel > declaimed the following: > >> On 04/29/2015 10:16 AM, Grant Edwards wrote: > >> >>> raise ParameterError, 'Parameter has to be an int' >>> if n < 0: >> >> Better: if length < 0:

Is my implementation of happy number OK

2015-04-30 Thread Cecil Westerhof
I implemented happy_number function: _happy_set = { '1' } _unhappy_set= set() def happy_number(n): """ Check if a number is a happy number https://en.wikipedia.org/wiki/Happy_number """ def create_current(n): current_array =

mixing set and list operations

2015-04-30 Thread Tim
I noticed this today, using Python2.7 or 3.4, and wondered if it is implementation dependent: You can use 'extend' to add set elements to a list and use 'update' to add list elements to a set. >>> m = ['one', 'two'] >>> p = set(['three', 'four']) >>> m.extend(p) >>> m ['one', 'two', 'four', 'th

Re: mixing set and list operations

2015-04-30 Thread Ian Kelly
On Thu, Apr 30, 2015 at 10:07 AM, Tim wrote: > I noticed this today, using Python2.7 or 3.4, and wondered if it is > implementation dependent: > > You can use 'extend' to add set elements to a list and use 'update' to add > list elements to a set. It's not implementation dependent. Both methods

l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those programs more slowly. Is there a way to circumvent Python claiming all the 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: l = range(int(1E9))

2015-04-30 Thread Grant Edwards
On 2015-04-30, Cecil Westerhof wrote: > If I execute: > l = range(int(1E9) > > The python process gobbles up all the memory and is killed. The > problem is that after this my swap is completely used, because other > processes have swapped to it. This make those programs more slowly. > Is there

Re: mixing set and list operations

2015-04-30 Thread Carl Meyer
Hi Tim, On 04/30/2015 10:07 AM, Tim wrote: > I noticed this today, using Python2.7 or 3.4, and wondered if it is > implementation dependent: > > You can use 'extend' to add set elements to a list and use 'update' to add > list elements to a set. > m = ['one', 'two'] p = set(['three',

Re: l = range(int(1E9))

2015-04-30 Thread Jon Ribbens
On 2015-04-30, Cecil Westerhof wrote: > If I execute: > l = range(int(1E9) > > The python process gobbles up all the memory and is killed. The > problem is that after this my swap is completely used, because other > processes have swapped to it. This make those programs more slowly. Is > there

Re: l = range(int(1E9))

2015-04-30 Thread Terry Reedy
On 4/30/2015 12:06 PM, Cecil Westerhof wrote: If I execute: l = range(int(1E9) you get a SyntaxError The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those programs

Re: mixing set and list operations

2015-04-30 Thread Ben Finney
Tim writes: > You can use 'extend' to add set elements to a list and use 'update' to > add list elements to a set. And you can use both of those methods to add items from a file:: >>> foo = ['one', 'two'] >>> bar = open('/usr/share/common-licenses/GPL-3') >>> foo.extend(bar) >>>

Re: l = range(int(1E9))

2015-04-30 Thread Gary Herron
On 04/30/2015 09:06 AM, Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those programs more slowly. Is there a

Re: Is my implementation of happy number OK

2015-04-30 Thread Jon Ribbens
On 2015-04-30, Cecil Westerhof wrote: > Besides it need some documentation: is it a good implementation? Or > are there things I should do differently? Here's an alternative implementation which is a bit neater: def find_happy(maximum): """Return set of happy numbers between 1 and `m

Re: l = range(int(1E9))

2015-04-30 Thread Rob Gaddi
On Thu, 30 Apr 2015 10:05:44 -0700, Gary Herron wrote: > On 04/30/2015 09:06 AM, Cecil Westerhof wrote: >> If I execute: >> l = range(int(1E9) >> >> The python process gobbles up all the memory and is killed. The problem >> is that after this my swap is completely used, because other processe

Re: l = range(int(1E9))

2015-04-30 Thread Ben Finney
Jon Ribbens writes: > On 2015-04-30, Cecil Westerhof wrote: > > If I execute: > > l = range(int(1E9) > > > > The python process gobbles up all the memory and is killed. […] Is > > there a way to circumvent Python claiming all the memory? You seem to be asking for a way to stop a program doi

Re: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 18:33 CEST schreef Grant Edwards: > On 2015-04-30, Cecil Westerhof wrote: >> If I execute: >> l = range(int(1E9) >> >> The python process gobbles up all the memory and is killed. The >> problem is that after this my swap is completely used, because >> other processes have

Re: Is my implementation of happy number OK

2015-04-30 Thread Ian Kelly
On Thu, Apr 30, 2015 at 9:59 AM, Cecil Westerhof wrote: > I implemented happy_number function: > _happy_set = { '1' } > _unhappy_set= set() > > def happy_number(n): > """ > Check if a number is a happy number > https://en.wikipedia.org/wiki/Happy_number

Re: l = range(int(1E9))

2015-04-30 Thread Ben Finney
Cecil Westerhof writes: > That works, yes. Now I get a MemoryError and the other processes are > left alone. Now determining what are the best values. I would strongly recommend that “best values” includes “run Python version >= 3”. One of the many problems you avoid by leaving Python 2 behind

Re: mixing set and list operations

2015-04-30 Thread Tim
On Thursday, April 30, 2015 at 1:05:05 PM UTC-4, Ben Finney wrote: > Tim writes: > > You can use 'extend' to add set elements to a list and use 'update' to > > add list elements to a set. > > And you can use both of those methods to add items from a file:: > > >>> foo = ['one', 'two'] > >

Re: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 18:55 CEST schreef Jon Ribbens: > On 2015-04-30, Cecil Westerhof wrote: >> If I execute: >> l = range(int(1E9) >> >> The python process gobbles up all the memory and is killed. The >> problem is that after this my swap is completely used, because >> other processes have sw

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: l = range(int(1E9))

2015-04-30 Thread Gisle Vanem
Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those programs more slowly. Is there a way to circumvent Pyth

Re: l = range(int(1E9))

2015-04-30 Thread alister
On Thu, 30 Apr 2015 20:23:31 +0200, Gisle Vanem wrote: > Cecil Westerhof wrote: > >> If I execute: >> l = range(int(1E9) >> >> The python process gobbles up all the memory and is killed. The problem >> is that after this my swap is completely used, because other processes >> have swapped to

Re: Is my implementation of happy number OK

2015-04-30 Thread Dave Angel
On 04/30/2015 11:59 AM, Cecil Westerhof wrote: I implemented happy_number function: _happy_set = { '1' } _unhappy_set= set() def happy_number(n): """ Check if a number is a happy number https://en.wikipedia.org/wiki/Happy_number """

Re: l = range(int(1E9))

2015-04-30 Thread Dave Angel
On 04/30/2015 02:48 PM, alister wrote: On Thu, 30 Apr 2015 20:23:31 +0200, Gisle Vanem wrote: Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other pro

Re: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 19:12 CEST schreef Rob Gaddi: > This also leads to a unrelated question, Cecil. Given that you > really are just starting to get your Python feet under you, why are > you using Python2? Python3 is the standard now, Python2 is really > just given legacy support. I'd understa

Re: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 19:41 CEST schreef Ben Finney: > Cecil Westerhof writes: > >> That works, yes. Now I get a MemoryError and the other processes >> are left alone. Now determining what are the best values. > > I would strongly recommend that “best values” includes “run Python > version >= 3

Re: Lucky numbers in Python

2015-04-30 Thread Cecil Westerhof
Because I want the code to work with Python 3 also, the code is now: def lucky_numbers(n): """ Lucky numbers from 1 up-to n http://en.wikipedia.org/wiki/Lucky_number """ if n < 3: return [1] sieve = list(range(1, n + 1, 2)) si

Re: Lucky numbers in Python

2015-04-30 Thread Dave Angel
On 04/30/2015 02:55 PM, Cecil Westerhof wrote: Because I want the code to work with Python 3 also, the code is now: def lucky_numbers(n): """ Lucky numbers from 1 up-to n http://en.wikipedia.org/wiki/Lucky_number """ if n < 3: return

Re: Is my implementation of happy number OK

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 19:37 CEST schreef Ian Kelly: Most I still have to digest. ;-) > On Thu, Apr 30, 2015 at 9:59 AM, Cecil Westerhof wrote: >> return (current_array, ''.join(current_array)) > > You don't seem to be actually using current_array for anything, so > why not just return the stri

Re: seek operation in python

2015-04-30 Thread Larry Hudson
On 04/30/2015 01:06 AM, Cecil Westerhof wrote: [snip] I wrote a module where I have: def get_indexed_message(message_filename, index): """ Get index message from a file, where 0 gets the first message """ return open(expanduser(message_filename), 'r').r

Re: l = range(int(1E9))

2015-04-30 Thread Roel Schroeven
Grant Edwards schreef op 2015-04-30 18:33: On 2015-04-30, Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make tho

Rounding a number

2015-04-30 Thread Seymore4Head
I have this page book marked. https://mkaz.com/2012/10/10/python-string-format/ I am getting numbers from sixty thousand to two hundred thousand. I would like to round them to the nearest thousand. So 65,253 should read 65,000. How? Total=2100 for x in range (10,35): count=1000/x print ("

Re: Rounding a number

2015-04-30 Thread Thijs Engels
round(65253, -3) might be what you are looking for... On Thu, Apr 30, 2015, at 21:49, Seymore4Head wrote: > I have this page book marked. > https://mkaz.com/2012/10/10/python-string-format/ > > I am getting numbers from sixty thousand to two hundred thousand. > I would like to round them to the

Re: Rounding a number

2015-04-30 Thread Mark Lawrence
On 30/04/2015 21:00, Thijs Engels wrote: On Thu, Apr 30, 2015, at 21:49, Seymore4Head wrote: I have this page book marked. https://mkaz.com/2012/10/10/python-string-format/ I am getting numbers from sixty thousand to two hundred thousand. I would like to round them to the nearest thousand. So 6

Re: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 20:59 CEST schreef Dave Angel: > On 04/30/2015 02:48 PM, alister wrote: >> On Thu, 30 Apr 2015 20:23:31 +0200, Gisle Vanem wrote: >> >>> Cecil Westerhof wrote: >>> If I execute: l = range(int(1E9) The python process gobbles up all the memory and is kille

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: l = range(int(1E9))

2015-04-30 Thread Mark Lawrence
On 30/04/2015 19:50, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 19:12 CEST schreef Rob Gaddi: This also leads to a unrelated question, Cecil. Given that you really are just starting to get your Python feet under you, why are you using Python2? Python3 is the standard now, Python2 is really

Re: Is my implementation of happy number OK

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 20:53 CEST schreef Dave Angel: > On 04/30/2015 11:59 AM, Cecil Westerhof wrote: >> I implemented happy_number function: >> _happy_set = { '1' } >> _unhappy_set= set() >> >> def happy_number(n): >> """ >> Check if a number is a happy number >> https://en.wikipedia.o

Nuitka Progress in Spring 2015

2015-04-30 Thread Mark Lawrence
Sales and marketing doesn't appear to be Kay Hayen's great strength so I'm taking a massive liberty and flagging Nuitka up here anyway. http://nuitka.net/posts/nuitka-progress-spring-2015.html -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our langua

Re: l = range(int(1E9))

2015-04-30 Thread ElChino
Mark Lawrence wrote: You might find this useful then in you haven't already seen it https://docs.python.org/3/howto/pyporting.html The main reason I haven't switched to Python3 (from 2.7.4/MSVC), is fear of a major breakage. How can I be certain that even if I install to different directories,

Re: seek operation in python

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 21:38 CEST schreef Larry Hudson: > On 04/30/2015 01:06 AM, Cecil Westerhof wrote: > [snip] > >> I wrote a module where I have: >> def get_indexed_message(message_filename, index): >> """ >> Get index message from a file, where 0 gets the first message >> """ >> >> return op

Re: Is my implementation of happy number OK

2015-04-30 Thread Dave Angel
On 04/30/2015 04:35 PM, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 20:53 CEST schreef Dave Angel: Finally, I did some testing on Jon Ribben's version. His was substantially faster for smaller sets, and about the same for 10*7. So it's likely it'll be slower than yours and mine for 10**8. B

Re: l = range(int(1E9))

2015-04-30 Thread Tim Chase
On 2015-04-30 22:18, Cecil Westerhof wrote: > Op Thursday 30 Apr 2015 20:59 CEST schreef Dave Angel: >> ulimit is your friend if you've got a program that wants to gobble >> up all of swap space. > > Yes, my system is openSUSE 64 bit. I really should look into ulimit. > The default is: [snip] >

Re: Rounding a number

2015-04-30 Thread Seymore4Head
On Thu, 30 Apr 2015 22:00:17 +0200, Thijs Engels wrote: >round(65253, -3) > >might be what you are looking for... > > >On Thu, Apr 30, 2015, at 21:49, Seymore4Head wrote: >> I have this page book marked. >> https://mkaz.com/2012/10/10/python-string-format/ >> >> I am getting numbers from sixty t

Re: l = range(int(1E9))

2015-04-30 Thread Chris Angelico
On Fri, May 1, 2015 at 7:23 AM, ElChino wrote: > Mark Lawrence wrote: > >> You might find this useful then in you haven't already seen it >> https://docs.python.org/3/howto/pyporting.html > > > The main reason I haven't switched to Python3 (from 2.7.4/MSVC), > is fear of a major breakage. How can

Re: Rounding a number

2015-04-30 Thread Dave Angel
On 04/30/2015 06:35 PM, Seymore4Head wrote: On Thu, 30 Apr 2015 22:00:17 +0200, Thijs Engels wrote: round(65253, -3) might be what you are looking for... On Thu, Apr 30, 2015, at 21:49, Seymore4Head wrote: I have this page book marked. https://mkaz.com/2012/10/10/python-string-format/ I a

Re: l = range(int(1E9))

2015-04-30 Thread ElChino
Chris Angelico wrote: > Very easily and simply: Python 3 and Python 2 will always install separately, and the only possible conflicts are over the "python" command in PATH and which program is associated with ".py" files. You can fix both of them by installing a recent version of Python and usin

Re: l = range(int(1E9))

2015-04-30 Thread Ben Finney
Chris Angelico writes: > Very easily and simply: Python 3 and Python 2 will always install > separately, and the only possible conflicts are over the "python" > command in PATH and which program is associated with ".py" files. Calling ‘python’ is now ambiguous, and with Python 2 slipping inexora

Use ‘python2’ or ‘python3’, explicit is better than implicit (was: l = range(int(1E9)))

2015-04-30 Thread Ben Finney
Chris Angelico writes: > Very easily and simply: Python 3 and Python 2 will always install > separately, and the only possible conflicts are over the "python" > command in PATH and which program is associated with ".py" files. Using the ‘python’ command is now ambiguous, and with Python 2 slippi

Re: l = range(int(1E9))

2015-04-30 Thread Chris Angelico
On Fri, May 1, 2015 at 9:12 AM, Ben Finney wrote: > Chris Angelico writes: > >> Very easily and simply: Python 3 and Python 2 will always install >> separately, and the only possible conflicts are over the "python" >> command in PATH and which program is associated with ".py" files. > > Calling ‘

Re: Is my implementation of happy number OK

2015-04-30 Thread Jon Ribbens
On 2015-04-30, Dave Angel wrote: > Finally, I did some testing on Jon Ribben's version. His was > substantially faster for smaller sets, and about the same for 10*7. So > it's likely it'll be slower than yours and mine for 10**8. You know what they say about assumptions. Actually, my version

Re: Is my implementation of happy number OK

2015-04-30 Thread Dave Angel
On 04/30/2015 07:31 PM, Jon Ribbens wrote: On 2015-04-30, Dave Angel wrote: Finally, I did some testing on Jon Ribben's version. His was substantially faster for smaller sets, and about the same for 10*7. So it's likely it'll be slower than yours and mine for 10**8. You know what they say a

Re: Use 'python2' or 'python3', explicit is better than implicit (was: l = range(int(1E9)))

2015-04-30 Thread Rustom Mody
On Friday, May 1, 2015 at 4:50:45 AM UTC+5:30, Ben Finney wrote: > Chris Angelico writes: > > > Very easily and simply: Python 3 and Python 2 will always install > > separately, and the only possible conflicts are over the "python" > > command in PATH and which program is associated with ".py" fi

Re: seek operation in python

2015-04-30 Thread Larry Hudson
On 04/30/2015 01:50 PM, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 21:38 CEST schreef Larry Hudson: On 04/30/2015 01:06 AM, Cecil Westerhof wrote: [snip] I wrote a module where I have: def get_indexed_message(message_filename, index): """ Get index message from a file, where 0 gets the fi

Re: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 22:53 CEST schreef Mark Lawrence: > On 30/04/2015 19:50, Cecil Westerhof wrote: >> Op Thursday 30 Apr 2015 19:12 CEST schreef Rob Gaddi: >> >>> This also leads to a unrelated question, Cecil. Given that you >>> really are just starting to get your Python feet under you, why

Re: l = range(int(1E9))

2015-04-30 Thread Mark Lawrence
On 01/05/2015 05:19, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 22:53 CEST schreef Mark Lawrence: On 30/04/2015 19:50, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 19:12 CEST schreef Rob Gaddi: This also leads to a unrelated question, Cecil. Given that you really are just starting to g

Re: l = range(int(1E9))

2015-04-30 Thread Steven D'Aprano
On Fri, 1 May 2015 02:06 am, Cecil Westerhof wrote: > If I execute: > l = range(int(1E9) Others have already answered your questions about memory. Let me answer the question you didn't ask about style :-) Don't use "l" as a variable name, as it looks too much like 1. Better to use L, or ev

Re: Is my implementation of happy number OK

2015-04-30 Thread Cecil Westerhof
Op Friday 1 May 2015 01:52 CEST schreef Dave Angel: > On 04/30/2015 07:31 PM, Jon Ribbens wrote: >> On 2015-04-30, Dave Angel wrote: >>> Finally, I did some testing on Jon Ribben's version. His was >>> substantially faster for smaller sets, and about the same for >>> 10*7. So it's likely it'll be

Re: Nuitka Progress in Spring 2015

2015-04-30 Thread Steven D'Aprano
On Fri, 1 May 2015 07:01 am, Mark Lawrence wrote: > Sales and marketing doesn't appear to be Kay Hayen's great strength so > I'm taking a massive liberty and flagging Nuitka up here anyway. > > http://nuitka.net/posts/nuitka-progress-spring-2015.html Anyone care to summarise the highlights for t

Re: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Friday 1 May 2015 01:12 CEST schreef Ben Finney: > Chris Angelico writes: > >> Very easily and simply: Python 3 and Python 2 will always install >> separately, and the only possible conflicts are over the "python" >> command in PATH and which program is associated with ".py" files. > > Calling

Re: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Friday 1 May 2015 06:42 CEST schreef Steven D'Aprano: > On Fri, 1 May 2015 02:06 am, Cecil Westerhof wrote: > >> If I execute: >> l = range(int(1E9) > > > Others have already answered your questions about memory. Let me > answer the question you didn't ask about style :-) That can be very usef

Re: l = range(int(1E9))

2015-04-30 Thread Steven D'Aprano
On Fri, 1 May 2015 03:20 am, Ben Finney wrote: > Jon Ribbens writes: > >> On 2015-04-30, Cecil Westerhof wrote: >> > If I execute: >> > l = range(int(1E9) >> > >> > The python process gobbles up all the memory and is killed. […] Is >> > there a way to circumvent Python claiming all the memory?

Re: Nuitka Progress in Spring 2015

2015-04-30 Thread Ben Finney
Steven D'Aprano writes: > On Fri, 1 May 2015 07:01 am, Mark Lawrence wrote: > > > http://nuitka.net/posts/nuitka-progress-spring-2015.html > > Anyone care to summarise the highlights Nuitka Progress in Spring 2015 * SSA (Single State Assignment Form): will allow Nuitka to be an *optimising* c

Re: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 23:41 CEST schreef Tim Chase: > On 2015-04-30 22:18, Cecil Westerhof wrote: >> Op Thursday 30 Apr 2015 20:59 CEST schreef Dave Angel: >>> ulimit is your friend if you've got a program that wants to gobble >>> up all of swap space. >> >> Yes, my system is openSUSE 64 bit. I

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: l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
Op Friday 1 May 2015 07:20 CEST schreef Steven D'Aprano: > Some programming language virtual machines limit how much memory > they will use. The CPython VM isn't one of those, although I > understand that both Jython and IronPython are. (I may be wrong -- Jython runs in the JVM, so Jython is. --

Looks like Python 3 files do not confirm to Python 3

2015-04-30 Thread Cecil Westerhof
On my system in: /usr/lib/python3.4/site-packages/ndg/httpsclient/ssl_peer_verification.py it says: try: from ndg.httpsclient.subj_alt_name import SubjectAltName from pyasn1.codec.der import decoder as der_decoder SUBJ_ALT_NAME_SUPPORT = True except ImportError, e: