Re: [Tutor] garbage collecting

2014-01-08 Thread Mark Lawrence
On 08/01/2014 04:41, Keith Winston wrote: Iirc, Python periodically cleans memory of bits & pieces that are no longer being used. I periodically do something stupid -- I mean experimental -- and end up with a semi-locked up system. Sometimes it comes back, sometimes everything after that point r

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-08 Thread Mark Lawrence
On 08/01/2014 03:36, Keith Winston wrote: Hey Steven, That's a cool primes module, I'm going to look that over more carefully. I can see that you've thought through this stuff before ;) And yeah, I'd like to see your Stopwatch code... I haven't looked at "with" yet, that's interesting. As usual

Re: [Tutor] python 3.3 split method confusion

2014-01-08 Thread Peter Otten
Danny Yoo wrote: > One of the common cases for split() is to break a line into a list of > words, for example. > > # 'hello this is a test'.split() > ['hello', 'this', 'is', 'a', 'test'] > # > > The Standard Library can

Re: [Tutor] garbage collecting

2014-01-08 Thread Keith Winston
well, fair enough. Generally, the issue involves instances when Python will come back, but it might take several minutes or much longer. And weird behaviour ensues: like timers I put on the program don't actually time the amount of time it's busy (by a very, very large margin). Also, often several

Re: [Tutor] garbage collecting

2014-01-08 Thread Mark Lawrence
On 08/01/2014 09:30, Keith Winston wrote: well, fair enough. Generally, the issue involves instances when Python will come back, but it might take several minutes or much longer. And weird behaviour ensues: like timers I put on the program don't actually time the amount of time it's busy (by a ve

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-08 Thread Keith Winston
Yes, I did read the context manager stuff, but I can only absorb a bit of it, I just don't have the background. It's getting better though. Plus I think most things will come only after I play with them, and I haven't really played much with wrappers, decorators and the like. Which is fine, the yea

Re: [Tutor] garbage collecting

2014-01-08 Thread Alan Gauld
On 08/01/14 08:15, Mark Lawrence wrote: I just saw where I could do os.system('python'), but in restarting the interpreter I'd lose everything currently loaded: my real question involves merely pushing the garbage collector into action, I think. Don't do that! You are not restarting the interp

Re: [Tutor] garbage collecting

2014-01-08 Thread Mark Lawrence
On 08/01/2014 10:41, Alan Gauld wrote: On 08/01/14 08:15, Mark Lawrence wrote: Did I? :) I just saw where I could do os.system('python'), but in restarting the interpreter I'd lose everything currently loaded: my real question involves merely pushing the garbage collector into action, I thi

Re: [Tutor] garbage collecting

2014-01-08 Thread Steven D'Aprano
On Tue, Jan 07, 2014 at 11:41:53PM -0500, Keith Winston wrote: > Iirc, Python periodically cleans memory of bits & pieces that are no longer > being used. I periodically do something stupid -- I mean experimental -- > and end up with a semi-locked up system. Sometimes it comes back, > sometimes eve

Re: [Tutor] garbage collecting

2014-01-08 Thread Alan Gauld
On 08/01/14 10:50, Mark Lawrence wrote: On 08/01/2014 10:41, Alan Gauld wrote: On 08/01/14 08:15, Mark Lawrence wrote: Did I? :) Oops, one too many lines deleted. Sorry Mark. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldph

Re: [Tutor] OverflowError: cannot fit 'long' into an index-sized integer

2014-01-08 Thread Steven D'Aprano
On Tue, Jan 07, 2014 at 10:36:56PM -0500, Keith Winston wrote: > And yeah, I'd like to see your Stopwatch code... I haven't looked at "with" > yet, that's interesting. As usual, I don't totally get it... Okay, let's talk about a common pattern in Python code: try: do some stuff finally: c

Re: [Tutor] garbage collecting

2014-01-08 Thread spir
On 01/08/2014 10:30 AM, Keith Winston wrote: well, fair enough. Generally, the issue involves instances when Python will come back, but it might take several minutes or much longer. And weird behaviour ensues: like timers I put on the program don't actually time the amount of time it's busy (by a

Re: [Tutor] garbage collecting

2014-01-08 Thread Steven D'Aprano
On Wed, Jan 08, 2014 at 12:43:06PM +0100, spir wrote: > [Just wildly guessing, don't know your app & code. Can you reduce it to a > minimal still manifesting similar bug?] Try (or rather, *don't* try): import sys list(range(sys.maxsize)) That ought to do it :-) (Note: depending on your opera

Re: [Tutor] garbage collecting

2014-01-08 Thread Keith Winston
Well, thanks everyone. I get the picture. And there's nothing subtle going on here: I'm playing around, trying to factor million-digit numbers and the like. No biggie, this was interesting. ___ Tutor maillist - Tutor@python.org To unsubscribe or change

[Tutor] need help how to run it on python 3.3

2014-01-08 Thread S Tareq
need help how to run it on python 3.3, or change it to python 3.3 when i run it says syntax error if i run it on python 2.7 it works.  # Import statements import random import datetime #Arrays to store the definitions and keywords read from the file keywords=[]; definition=[]; correctAnswer=[];

[Tutor] recursion depth

2014-01-08 Thread Keith Winston
I've been playing with recursion, it's very satisfying. However, it appears that even if I sys.setrecursionlimit(10), it blows up at about 24,000 (appears to reset IDLE). I guess there must be a lot of overhead with recursion, if only 24k times are killing my memory? I'm playing with a challe

Re: [Tutor] garbage collecting

2014-01-08 Thread Oscar Benjamin
On Jan 8, 2014 5:51 PM, "Keith Winston" wrote: > > Well, thanks everyone. I get the picture. And there's nothing subtle going on here: I'm playing around, trying to factor million-digit numbers and the like. No biggie, this was interesting. Million digit numbers will use up some memory. Perhaps a

Re: [Tutor] need help how to run it on python 3.3

2014-01-08 Thread Mark Lawrence
On 08/01/2014 18:19, S Tareq wrote: need help how to run it on python 3.3, or change it to python 3.3 when i run it says syntax error if i run it on python 2.7 it works. if(counter%2==0): Please remove those unneeded brackets, this is a Python list, not C :) print "Please Se

Re: [Tutor] recursion depth

2014-01-08 Thread Emile van Sebille
On 1/8/2014 12:25 PM, Keith Winston wrote: I've been playing with recursion, it's very satisfying. However, it appears that even if I sys.setrecursionlimit(10), it blows up at about 24,000 (appears to reset IDLE). I guess there must be a lot of overhead with recursion, if only 24k times are

Re: [Tutor] need help how to run it on python 3.3

2014-01-08 Thread Danny Yoo
Hi S Tareq, You probably want to review the "What's new in Python 3" document, with close attention to the "Common Stumbing Blocks" section: http://docs.python.org/3.0/whatsnew/3.0.html#common-stumbling-blocks Have you read this document already?

Re: [Tutor] garbage collecting

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 3:30 PM, Oscar Benjamin wrote: > The garbage collector has nothing to do with the memory usage of immutable > types like ints. There are deallocated instantly when the last reference > you hold is cleared (in CPython). So if you run out of memory because of > them then it is

Re: [Tutor] recursion depth

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 3:42 PM, Emile van Sebille wrote: > > Without seeing your code it's hard to be specific, but it's obvious you'll > need to rethink your approach. :) Yes, it's clear I need to do the bulk of it without recusion, I haven't really thought about how to do that. I may or may

Re: [Tutor] garbage collecting

2014-01-08 Thread Oscar Benjamin
On Jan 8, 2014 9:11 PM, "Keith Winston" wrote: > > > On Wed, Jan 8, 2014 at 3:30 PM, Oscar Benjamin wrote: >> >> The garbage collector has nothing to do with the memory usage of immutable types like ints. There are deallocated instantly when the last reference you hold is cleared (in CPython). So

Re: [Tutor] recursion depth

2014-01-08 Thread eryksun
On Wed, Jan 8, 2014 at 3:25 PM, Keith Winston wrote: > I've been playing with recursion, it's very satisfying. > > However, it appears that even if I sys.setrecursionlimit(10), it blows > up at about 24,000 (appears to reset IDLE). I guess there must be a lot of > overhead with recursion, if o

Re: [Tutor] need help how to run it on python 3.3

2014-01-08 Thread Steve Mayer
You might want to check out the '2to3' program to convert Python 2.x code to Python 3.x code. The following command worked to change your code to runnable Python 3.x code: 2to3 -w -- Steve Mayer smaye...@me.com On 8 Jan 2014, at 10:19, S Tareq wrote: need help how to run it on python

Re: [Tutor] need help how to run it on python 3.3

2014-01-08 Thread Danny Yoo
Hi S Tareq, If you can, next time please just copy and paste the error message as plain text. Please avoid screenshots unless they really are relevant to the problem at hand. There are good reasons why you should prefer plain text when asking questions on a mailing list like this one. (1) Scree

Re: [Tutor] recursion depth

2014-01-08 Thread spir
On 01/08/2014 10:11 PM, Keith Winston wrote: On Wed, Jan 8, 2014 at 3:42 PM, Emile van Sebille wrote: Without seeing your code it's hard to be specific, but it's obvious you'll need to rethink your approach. :) Yes, it's clear I need to do the bulk of it without recusion, I haven't reall

Re: [Tutor] recursion depth

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 4:23 PM, eryksun wrote: > You can create a worker thread with a larger stack using the threading > module. On Windows the upper limit is 256 MiB, so give this a try: > quite excellent, mwahaha... another shovel to help me excavate out the bottom of my hole... I'll play wi

Re: [Tutor] recursion depth

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 5:15 PM, spir wrote: > Funny and useful exercise in recursion: write a func that builds str and > repr expressions of any object, whatever its attributes, inductively. Eg > with > Hmm, can't say I get the joke. I haven't really played with repr, though I think I understand

Re: [Tutor] need help how to run it on python 3.3

2014-01-08 Thread Mark Lawrence
On 08/01/2014 20:54, S Tareq wrote: On Wednesday, 8 January 2014, 20:46, Danny Yoo wrote: Hi S Tareq, You probably want to review the "What's new in Python 3" document, with close attention to the "Common Stumbing Blocks" section: http://docs.python.org/3.0/whatsnew/3.0.html#common-stumbling-

Re: [Tutor] recursion depth

2014-01-08 Thread Dave Angel
On Wed, 8 Jan 2014 16:23:06 -0500, eryksun wrote: On Wed, Jan 8, 2014 at 3:25 PM, Keith Winston wrote: > I've been playing with recursion, it's very satisfying. > > However, it appears that even if I sys.setrecursionlimit(10), it blows > up at about 24,000 (appears to reset IDLE). I gue

Re: [Tutor] need help how to run it on python 3.3

2014-01-08 Thread Dave Angel
On Wed, 8 Jan 2014 20:54:09 + (GMT), S Tareq wrote: ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor This is a text newsgroup. Html messages and attachments of

Re: [Tutor] recursion depth

2014-01-08 Thread Keith Winston
On Wed, Jan 8, 2014 at 6:16 PM, Dave Angel wrote: > I can't see the bodies of any of your messages (are you perchance posting > in html? ), but I think there's a good chance you're abusing recursion and > therefore hitting the limit much sooner than necessary. I've seen some code > samples here

Re: [Tutor] garbage collecting

2014-01-08 Thread eryksun
On Wed, Jan 8, 2014 at 3:30 PM, Oscar Benjamin wrote: > The garbage collector has nothing to do with the memory usage of immutable > types like ints. There are deallocated instantly when the last reference you > hold is cleared (in CPython). So if you run out of memory because of them > then it is

Re: [Tutor] garbage collecting

2014-01-08 Thread Keith Winston
On Thu, Jan 9, 2014 at 12:27 AM, eryksun wrote: > The old float freelist was the same design as the one for 2.x int > (PyInt, not PyLong), which grows without bound. The design also > allocates objects in 1 KiB blocks (approx. size). glibc's malloc will > use the heap for a block that's this smal