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

2015-05-03 Thread Mark Lawrence
On 03/05/2015 12:30, Chris Angelico wrote: On Sun, May 3, 2015 at 9:16 PM, Steven D'Aprano wrote: On Sun, 3 May 2015 12:16 pm, Mark Lawrence wrote: I doubt that six will ever make the standard library as 2.7 only has another five years in official support. By that time I suppose we'll to goi

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

2015-05-03 Thread Chris Angelico
On Sun, May 3, 2015 at 9:16 PM, Steven D'Aprano wrote: > On Sun, 3 May 2015 12:16 pm, Mark Lawrence wrote: > >> I doubt that six will ever make the standard library as 2.7 only has >> another five years in official support. By that time I suppose we'll to >> going through the porting pain all ove

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

2015-05-03 Thread Chris Angelico
On Sun, May 3, 2015 at 9:15 PM, Steven D'Aprano wrote: > Or if you prefer: > > try: > range = xrange > except NameError: > pass > > and just use range. I prefer this idiom, on the basis that code should be written for the more recent version, and have minimal code to support older version

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

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 02:51 pm, Ian Kelly wrote: > On Sat, May 2, 2015 at 5:51 PM, Terry Reedy wrote: >> On 5/2/2015 5:31 PM, Ian Kelly wrote: >> >>> Would it have been better if range() had been implemented as xrange() >>> from the beginning? Sure, that would have been great. Except for one >>> sma

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

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 12:16 pm, Mark Lawrence wrote: > I doubt that six will ever make the standard library as 2.7 only has > another five years in official support.  By that time I suppose we'll to > going through the porting pain all over again with the transition from > Python 3 to Python 4.  Alri

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

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 08:33 am, BartC wrote: > OK, so it's just an irritation then, as a workaround has been available > for a long time. (For example, if you use xrange, it won't work on 3.x. > If you use range, then it might be inefficient on 2.x.) That is trivially easy to deal with. Put this at

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

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 07:40 am, Jon Ribbens wrote: > On 2015-05-02, BartC wrote: >> So do I, I think, if no-one is willing to admit that the original way of >> implementing range() was a glaring mistake. > > I think the issue is that nobody else here thinks the "original way" > of iterating was to

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

2015-05-03 Thread Chris Angelico
On Sun, May 3, 2015 at 8:32 PM, Steven D'Aprano wrote: > scripting > languages often lack a C-style for-loop, using a foreach loop instead. E.g. > I believe the canonical way to loop in bash is something like: > > for $i in `seq start stop` do ... > > (by memory). Newer versions of bash have

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

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 07:28 am, Tony the Tiger wrote: > On Fri, 01 May 2015 14:42:04 +1000, Steven D'Aprano wrote: > >> use "l" as a variable name, as it looks too much like 1 > > If you use a better font, they are very different. Besides, a variable > name cannot start with a digit (nor can it be

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

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 02:17 am, BartC wrote: > But for looping over a simple integer range, then using 'range' to > denote the range (and build a list as it used to do), was how it was > done. And earlier on people would have been porting coding code to > Python at which point a straightforward 'for

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

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 5:51 PM, Terry Reedy wrote: > On 5/2/2015 5:31 PM, Ian Kelly wrote: > >> Would it have been better if range() had been implemented as xrange() >> from the beginning? Sure, that would have been great. Except for one >> small detail: the iterator protocol didn't exist back the

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

2015-05-02 Thread Jon Ribbens
On 2015-05-03, Terry Reedy wrote: > On 5/2/2015 8:01 PM, Jon Ribbens wrote: >> On 2015-05-02, Terry Reedy wrote: >>> On 5/2/2015 5:40 PM, Jon Ribbens wrote: For information, it looks like xrange() was added on 26 Oct 1993, which pre-dates Python 1.0. >>> >>> 1.0 was released Feb 1991.

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

2015-05-02 Thread Terry Reedy
On 5/2/2015 8:01 PM, Jon Ribbens wrote: On 2015-05-02, Terry Reedy wrote: On 5/2/2015 5:40 PM, Jon Ribbens wrote: For information, it looks like xrange() was added on 26 Oct 1993, which pre-dates Python 1.0. 1.0 was released Feb 1991. 3.2 exactly 20 years later. No, you are thinking of 0.

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

2015-05-02 Thread Mark Lawrence
On 03/05/2015 03:07, Michael Torrie wrote: On 05/02/2015 04:33 PM, BartC wrote: OK, so it's just an irritation then, as a workaround has been available for a long time. (For example, if you use xrange, it won't work on 3.x. If you use range, then it might be inefficient on 2.x.) In both Python

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

2015-05-02 Thread Michael Torrie
On 05/02/2015 04:33 PM, BartC wrote: > OK, so it's just an irritation then, as a workaround has been available > for a long time. (For example, if you use xrange, it won't work on 3.x. > If you use range, then it might be inefficient on 2.x.) In both Python 2.7 and 3.3+, you can use the 3rd-part

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

2015-05-02 Thread Jon Ribbens
On 2015-05-02, BartC wrote: > On 02/05/2015 22:40, Jon Ribbens wrote: >> I think the issue is that nobody else here thinks the "original way" >> of iterating was to use range(), for anything other than extremely >> small ranges. > > What /is/ the way to iterate then? Other people have already exp

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

2015-05-02 Thread Jon Ribbens
On 2015-05-02, Terry Reedy wrote: > On 5/2/2015 5:40 PM, Jon Ribbens wrote: >> For information, it looks like xrange() was added on 26 Oct 1993, >> which pre-dates Python 1.0. > > 1.0 was released Feb 1991. 3.2 exactly 20 years later. No, you are thinking of 0.9, which was indeed February 1991.

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

2015-05-02 Thread Terry Reedy
On 5/2/2015 5:31 PM, Ian Kelly wrote: Would it have been better if range() had been implemented as xrange() from the beginning? Sure, that would have been great. Except for one small detail: the iterator protocol didn't exist back then. For loops originally used the getitem iterator protocol.

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

2015-05-02 Thread Terry Reedy
On 5/2/2015 5:40 PM, Jon Ribbens wrote: For information, it looks like xrange() was added on 26 Oct 1993, which pre-dates Python 1.0. 1.0 was released Feb 1991. 3.2 exactly 20 years later. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

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

2015-05-02 Thread Terry Reedy
On 5/2/2015 11:26 AM, BartC wrote: When I first looked at Python 20 or so years ago this seemed to be the standard way of writing a for-loop: for i in range(N): As Mark said, the actual syntax was originally for item in sequence: ... where sequence technically meant an object with

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

2015-05-02 Thread BartC
On 02/05/2015 22:40, Jon Ribbens wrote: On 2015-05-02, BartC wrote: So do I, I think, if no-one is willing to admit that the original way of implementing range() was a glaring mistake. I think the issue is that nobody else here thinks the "original way" of iterating was to use range(), for an

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

2015-05-02 Thread Mark Lawrence
On 02/05/2015 22:40, Jon Ribbens wrote: On 2015-05-02, BartC wrote: So do I, I think, if no-one is willing to admit that the original way of implementing range() was a glaring mistake. I think the issue is that nobody else here thinks the "original way" of iterating was to use range(), for an

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

2015-05-02 Thread Jon Ribbens
On 2015-05-02, BartC wrote: > So do I, I think, if no-one is willing to admit that the original way of > implementing range() was a glaring mistake. I think the issue is that nobody else here thinks the "original way" of iterating was to use range(), for anything other than extremely small range

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

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 3:28 PM, Tony the Tiger wrote: > On Fri, 01 May 2015 14:42:04 +1000, Steven D'Aprano wrote: > >> use "l" as a variable name, as it looks too much like 1 > > If you use a better font, they are very different. Besides, a variable > name cannot start with a digit (nor can it be

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

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 1:51 PM, BartC wrote: > On 02/05/2015 20:15, Mark Lawrence wrote: >> >> On 02/05/2015 19:34, BartC wrote: > > >>> OK, so it's the programmer's fault if as fundamental a concept as a >>> for-loop ranging over integers is implemented inefficiently. He has to >>> transform it i

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

2015-05-02 Thread Joel Goldstick
>> I give up. > > > So do I, I think, if no-one is willing to admit that the original way of > implementing range() was a glaring mistake. > > > -- > Bartc > It doesn't matter for small ranges. Anyway it was fixed. > > > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldsti

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

2015-05-02 Thread BartC
On 02/05/2015 20:15, Mark Lawrence wrote: On 02/05/2015 19:34, BartC wrote: OK, so it's the programmer's fault if as fundamental a concept as a for-loop ranging over integers is implemented inefficiently. He has to transform it into high-level terms, or has to reconstruct it somehow using a wh

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

2015-05-02 Thread Marko Rauhamaa
Mark Lawrence : > On 02/05/2015 19:34, BartC wrote: >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] [etc etc etc] > > I give up. Mark, you do a commendable job admonishing the forum participants against top-posting. Let

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

2015-05-02 Thread Marko Rauhamaa
BartC : > (I tried an empty loop counting to 1 billion in Python 2.x, using 'for > i in range'. It ran out of memory. Counting to 100 million instead, it > worked, but still used a massive 1.5GB RAM while doing so (and took 6 > seconds to count to 100M, not too bad for Python) > > Outside Python,

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

2015-05-02 Thread Mark Lawrence
On 02/05/2015 19:34, BartC wrote: On 02/05/2015 17:39, Mark Lawrence wrote: On 02/05/2015 17:17, BartC wrote: On 02/05/2015 16:40, Mark Lawrence wrote: for item in items: When did this change, or has it always been this way and you were simply using an idiom from other languages? Your ex

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

2015-05-02 Thread BartC
On 02/05/2015 17:39, Mark Lawrence wrote: On 02/05/2015 17:17, BartC wrote: On 02/05/2015 16:40, Mark Lawrence wrote: for item in items: When did this change, or has it always been this way and you were simply using an idiom from other languages? Your example is the equivalent of 'forall'

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

2015-05-02 Thread Mark Lawrence
On 02/05/2015 17:17, BartC wrote: On 02/05/2015 16:40, Mark Lawrence wrote: On 02/05/2015 16:26, BartC wrote: On 30/04/2015 18:20, Ben Finney wrote: Jon Ribbens writes: If you use xrange() instead of range() then you will get an iterator which will return each of the numbers in turn withou

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

2015-05-02 Thread BartC
On 02/05/2015 16:40, Mark Lawrence wrote: On 02/05/2015 16:26, BartC wrote: On 30/04/2015 18:20, Ben Finney wrote: Jon Ribbens writes: If you use xrange() instead of range() then you will get an iterator which will return each of the numbers in turn without any need to create an enormous li

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

2015-05-02 Thread Mark Lawrence
On 02/05/2015 16:26, BartC wrote: On 30/04/2015 18:20, Ben Finney wrote: Jon Ribbens writes: If you use xrange() instead of range() then you will get an iterator which will return each of the numbers in turn without any need to create an enormous list of all of them. If you use Python 3 in

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

2015-05-02 Thread BartC
On 30/04/2015 18:20, Ben Finney wrote: Jon Ribbens writes: If you use xrange() instead of range() then you will get an iterator which will return each of the numbers in turn without any need to create an enormous list of all of them. If you use Python 3 instead of the obsolescent Python 2,

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

2015-05-01 Thread Terry Reedy
On 5/1/2015 1:04 AM, Cecil Westerhof wrote: By the way: I also see python3.4 and python3.4m. Any idea where the m stands for? I never heard of that in 18 years of Python, and thought it must be an error, but putting 'python3.4b' into google search return this. https://stackoverflow.com/ques

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

2015-05-01 Thread Cecil Westerhof
Op Friday 1 May 2015 15:25 CEST schreef Michael Torrie: > On 04/30/2015 10:19 PM, Cecil Westerhof wrote: >>> I must also confess to being highly impressed, it's a breath of >>> fresh air having an apprentice Pythonista who is looking at doing >>> things the Pythonic way :) >> >> When in Rome, do a

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

2015-05-01 Thread Michael Torrie
On 04/30/2015 10:19 PM, Cecil Westerhof wrote: >> I must also confess to being highly impressed, it's a breath of >> fresh air having an apprentice Pythonista who is looking at doing >> things the Pythonic way :) > > When in Rome, do as the Romans do. > > Besides: there probably is a reason for t

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

2015-05-01 Thread Cecil Westerhof
Op Friday 1 May 2015 13:15 CEST schreef Thomas Lahn: > Cecil Westerhof wrote: > >> By the way: I also see python3.4 and python3.4m. Any idea where the >> m stands for? > > I googled for “python3.4m” and found as second result Eh, I could/should have done that myself. :-( Nice that you do not burn

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

2015-05-01 Thread Thomas 'PointedEars' Lahn
Cecil Westerhof wrote: > By the way: I also see python3.4 and python3.4m. Any idea where the m > stands for? I googled for “python3.4m” and found as second result In a nutshell: python3.4m was buil

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. --

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: 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: 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 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: 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 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 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: 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

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 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: 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: 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: 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: 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: 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

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: 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 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 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: 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 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: 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: 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: 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 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 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: 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: 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 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: L-system equations drawing tool

2014-07-18 Thread Terry Reedy
On 7/17/2014 5:38 PM, Yaşar Arabacı wrote: Hi, I wrote a small program to draw L-system equations using tkinter. You can find it on https://github.com/yasar11732/tklsystem It is still under development, but seems to be working nice so far. I could only try it on windows, but it should work on L

Re: L[:]

2014-01-14 Thread Terry Reedy
On 1/14/2014 5:42 AM, Albert-Jan Roskam wrote: I also found that item assignment ([1] below) is much faster > than using the more standard (I think) .append ([2]). # [1] for idx,item in enumerate(L[:]): if some_condition: L[idx] = foobarify(item) [1] *is* the standard way to sele

Re: L[:]

2014-01-14 Thread Albert-Jan Roskam
On 1/13/2014 4:00 AM, Laszlo Nagy wrote: > >> Unless L is aliased, this is silly code. > There is another use case. If you intend to modify a list within a for > loop that goes over the same list, then you need to iterate over a copy. > And this cannot be called an "alias" because it has

Re: L[:]

2014-01-13 Thread Terry Reedy
On 1/13/2014 4:00 AM, Laszlo Nagy wrote: Unless L is aliased, this is silly code. There is another use case. If you intend to modify a list within a for loop that goes over the same list, then you need to iterate over a copy. And this cannot be called an "alias" because it has no name: for i

Re: L[:]

2014-01-13 Thread Laszlo Nagy
Unless L is aliased, this is silly code. There is another use case. If you intend to modify a list within a for loop that goes over the same list, then you need to iterate over a copy. And this cannot be called an "alias" because it has no name: for idx,item in enumerate(L[:]): # do somet

Re: L[:]

2014-01-11 Thread Grant Edwards
On 2014-01-10, Terry Reedy wrote: > On 1/10/2014 12:38 PM, Albert-Jan Roskam wrote: >> In Python Cookbook, one of the authors (I forgot who) consistently used the >> "L[:]" idiom like below. If the second line simply starts with "L =" (so no >> "[:]") only the name "L" would be rebound, not the

Re: L[:]

2014-01-10 Thread Terry Reedy
On 1/10/2014 12:38 PM, Albert-Jan Roskam wrote: In Python Cookbook, one of the authors (I forgot who) consistently used the "L[:]" idiom like below. If the second line simply starts with "L =" (so no "[:]") only the name "L" would be rebound, not the underlying object. That was the authorś expl

Re: L[:]

2014-01-10 Thread Ned Batchelder
On 1/10/14 12:38 PM, Albert-Jan Roskam wrote: In Python Cookbook, one of the authors (I forgot who) consistently used the "L[:]" idiom like below. If the second line simply starts with "L =" (so no "[:]") only the name "L" would be rebound, not the underlying object. That was the authorś explan

Re: \l operation in regular expressions

2005-05-24 Thread Fredrik Lundh
"Kalle Anka" <[EMAIL PROTECTED]> wrote: > I've started to play around with regexps in Python and I tried > something like this > > print re.sub( r'(\bw\w+\b)', r'\u\1', 'will it work') > > and get > > \uwill it \uwork > > when I had expected > > Will it Work > > I tried to find some documentation