[issue37447] Nested For Loop in Python not working as Expected after cnt=2136

2019-06-29 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: @pradnyan The break statement [0] only exits the for loop where it's present in this the one where y is involved so the outer loop involving x will continue to execute. So after every attempt where y = 0 the cnt value succeeds and breaks out of

[issue37447] Nested For Loop in Python not working as Expected after cnt=2136

2019-06-29 Thread Pradnyan
anthonybaxter, barry, benjamin.peterson, eric.araujo, ezio.melotti, georg.brandl, gvanrossum, lemburg, mdk, ned.deily, pradnyan, tarek priority: normal severity: normal status: open title: Nested For Loop in Python not working as Expected after cnt=2136 type: behavior versions: Python 3.7 Adde

Re: how to exit from a nested loop in python

2019-02-09 Thread DL Neil
On 8/02/19 7:45 PM, Kaka wrote: for i in range(len(A.hp)): for j in range(len(run_parameters.bits_Mod)): req_slots[j] = math.ceil((A.T[i]) for g in Temp[i]["Available_ranges"][j]: for s in range(g[0], g[-1]): if (s+req_slots[j]-1) <=

Re: how to exit from a nested loop in python

2019-02-08 Thread Rurpy via Python-list
On Thursday, February 7, 2019 at 11:45:23 PM UTC-7, Kaka wrote: > for i in range(len(A.hp)): > > for j in range(len(run_parameters.bits_Mod)): > req_slots[j] = math.ceil((A.T[i]) > > for g in Temp[i]["Available_ranges"][j]: > for s in range(g[0], g[-1]): >

Re: how to exit from a nested loop in python

2019-02-08 Thread Peter Otten
Kaka wrote: > for i in range(len(A.hp)): > > for j in range(len(run_parameters.bits_Mod)): > req_slots[j] = math.ceil((A.T[i]) > > for g in Temp[i]["Available_ranges"][j]: > for s in range(g[0], g[-1]): > if (s+req_slots[j]-1) <= g[-1]: >

how to exit from a nested loop in python

2019-02-07 Thread Kaka
for i in range(len(A.hp)): for j in range(len(run_parameters.bits_Mod)): req_slots[j] = math.ceil((A.T[i]) for g in Temp[i]["Available_ranges"][j]: for s in range(g[0], g[-1]): if (s+req_slots[j]-1) <= g[-1]: if

Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
On Monday, February 26, 2018 at 12:57:25 PM UTC+5:30, Chris Angelico wrote: > On Mon, Feb 26, 2018 at 5:19 AM, wrote: > > Why we don’t use: > > > > for _ in _ in _ > > > > Instead of > > > > for _ in _: > > for _ in _: > > > > Ex: > > > > Names =

Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
On Monday, February 26, 2018 at 6:23:24 AM UTC+5:30, Rick Johnson wrote: > On Sunday, February 25, 2018 at 12:19:56 PM UTC-6, arya.ku...@gmail.com wrote: > > > Ex: > > > > Names = ["Arya","Pupun"] > > > > for name in Names: > >for c in name: > >print(c) > > > > instead use: > > >

Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
On Monday, February 26, 2018 at 6:20:06 AM UTC+5:30, Ian wrote: > On Sun, Feb 25, 2018 at 11:19 AM, wrote: > > Why we don’t use: > > > > for _ in _ in _ > > > > Instead of > > > > for _ in _: > > for _ in _: > > > > Ex: > > > > Names = ["Arya","Pupun"] > > > >

Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
On Monday, February 26, 2018 at 8:51:35 PM UTC+5:30, Ian wrote: > On Sun, Feb 25, 2018 at 8:05 PM, INADA Naoki wrote: > > https://docs.python.org/3.6/library/itertools.html#itertools.product > > I don't see how you would use itertools.product to do what the OP > asked

Re: For Loop Dilema [python-list]

2018-02-26 Thread Ian Kelly
On Sun, Feb 25, 2018 at 8:05 PM, INADA Naoki wrote: > https://docs.python.org/3.6/library/itertools.html#itertools.product I don't see how you would use itertools.product to do what the OP asked for. You could use itertools.chain.from_iterable, though: py> names =

Re: For Loop Dilema [python-list]

2018-02-25 Thread Chris Angelico
On Mon, Feb 26, 2018 at 5:19 AM, wrote: > Why we don’t use: > > for _ in _ in _ > > Instead of > > for _ in _: > for _ in _: > > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >for c in name: >print(c) > > instead use: > > for c in name in

Re: For Loop Dilema [python-list]

2018-02-25 Thread INADA Naoki
https://docs.python.org/3.6/library/itertools.html#itertools.product On Mon, Feb 26, 2018 at 3:19 AM, wrote: > Why we don’t use: > > for _ in _ in _ > > Instead of > > for _ in _: > for _ in _: > > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >

Re: For Loop Dilema [python-list]

2018-02-25 Thread Rick Johnson
On Sunday, February 25, 2018 at 12:19:56 PM UTC-6, arya.ku...@gmail.com wrote: > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >for c in name: >print(c) > > instead use: > > for c in name in Names: > print(c) Hmm. Why stop there? bit = ["kibbles"] bits = [bit,

Re: For Loop Dilema [python-list]

2018-02-25 Thread Ian Kelly
On Sun, Feb 25, 2018 at 11:19 AM, wrote: > Why we don’t use: > > for _ in _ in _ > > Instead of > > for _ in _: > for _ in _: > > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >for c in name: >print(c) > > instead use: > > for c in name in

For Loop Dilema [python-list]

2018-02-25 Thread arya . kumar2494
Why we don’t use: for _ in _ in _ Instead of for _ in _: for _ in _: Ex: Names = ["Arya","Pupun"] for name in Names: for c in name: print(c) instead use: for c in name in Names: print(c) -- https://mail.python.org/mailman/listinfo/python-list

Re: for loop in python

2016-04-28 Thread BartC
On 28/04/2016 10:34, g.v.aar...@skct.edu.in wrote: start_list = [5, 3, 1, 2, 4] square_list = [] # Your code here! for square_list in start_list: x = pow(start_list, 2) square_list.append(x) square_list.sort() print square_list TypeError: unsupported operand type(s) for ** or pow():

Re: for loop in python

2016-04-28 Thread Peter Otten
g.v.aar...@skct.edu.in wrote: > start_list = [5, 3, 1, 2, 4] > square_list = [] > > # Your code here! > for square_list in start_list: You are iterating over start_list, that's OK. But you are assigning the current value to square_list, a variable name that you already use for the list where

Re: for loop in python

2016-04-28 Thread Steven D'Aprano
On Thu, 28 Apr 2016 07:34 pm, g.v.aar...@skct.edu.in wrote: > start_list = [5, 3, 1, 2, 4] > square_list = [] Here you set square_list to a list. > # Your code here! > for square_list in start_list: .^ Here you set square_list to each item of the start_list. So the first time

for loop in python

2016-04-28 Thread g . v . aarthi
start_list = [5, 3, 1, 2, 4] square_list = [] # Your code here! for square_list in start_list: x = pow(start_list, 2) square_list.append(x) square_list.sort() print square_list TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int' Please provide me the solution for

[issue23045] json data iteration through loop in python

2014-12-12 Thread vegeshna satyanarayana raju
Changes by vegeshna satyanarayana raju satya.nani...@gmail.com: -- nosy: satyanani40 priority: normal severity: normal status: open title: json data iteration through loop in python ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue23045] json data iteration through loop in python

2014-12-12 Thread vegeshna satyanarayana raju
New submission from vegeshna satyanarayana raju: I have json data in following format {message:[frappe,websocerp,erpnext]} I want each name (frappe, websocerp, erpnext) in three iteration after that i can use as frappe.something.get_data() websocerp.something.get_data()

[issue23045] json data iteration through loop in python

2014-12-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is a bug tracker for issues in the Python language and standard library, not a service for learning how to program using Python. If you have an actual bug to report, you should give more detail including the actual code you used, the result you

Need help about for loop in python 3.2

2011-06-23 Thread kkiranmca
Hi i am new for this version and could please help me . -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help about for loop in python 3.2

2011-06-23 Thread Chris Rebert
On Wed, Jun 22, 2011 at 11:50 PM, kkiranmca kkiran...@gmail.com wrote: Hi i am new for this version and could please help me . You didn't pose an actual question... Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help about for loop in python 3.2

2011-06-23 Thread Ben Finney
kkiranmca kkiran...@gmail.com writes: Hi i am new for this version and could please help me . Welcome! Don't ask whether you can ask. Just ask. URL:http://catb.org/~esr/faqs/smart-questions.html -- \ “I put contact lenses in my dog's eyes. They had little | `\ pictures of

Re: How to write a simple shell loop in python?

2009-01-23 Thread Dietrich Bollmann
trying to write a simple shell loop in Python. My simple approach works fine - but the first output line after entering something is always indented by one blank. Is there any logic explanation for this? How can I get rid of the blank? Is there a smarter way to write a simple shell

Re: How to write a simple shell loop in python?

2009-01-21 Thread Steve Holden
Dietrich Bollmann wrote: Hi, I am trying to write a simple shell loop in Python. My simple approach works fine - but the first output line after entering something is always indented by one blank. Is there any logic explanation for this? How can I get rid of the blank

Re: How to write a simple shell loop in python?

2009-01-21 Thread Scott David Daniels
Dietrich Bollmann wrote: I am trying to write a simple shell loop in Python. My simple approach works fine - but the first output line after entering something is always indented by one blank. Is there any logic explanation for this? Yes How can I get rid of the blank? By not asking

How to write a simple shell loop in python?

2009-01-20 Thread Dietrich Bollmann
Hi, I am trying to write a simple shell loop in Python. My simple approach works fine - but the first output line after entering something is always indented by one blank. Is there any logic explanation for this? How can I get rid of the blank? Is there a smarter way to write a simple shell

Re: How to write a simple shell loop in python?

2009-01-20 Thread Saul Spatz
Dietrich Bollmann wrote: Hi, I am trying to write a simple shell loop in Python. My simple approach works fine - but the first output line after entering something is always indented by one blank. Is there any logic explanation for this? How can I get rid of the blank? Is there a smarter

Re: How to write a simple shell loop in python?

2009-01-20 Thread James Mills
statement's being in a loop. By the way, you don't need parens around the loop guard in python: while 1: (or as I prefer, while True:) work just fine. http://codepad.org/f2XSwsPo This component I wrote - just for the hell of it - (just for this thread) works nicely :) cheers James -- http

Re: How to write a simple shell loop in python?

2009-01-20 Thread Ben Finney
Dietrich Bollmann dir...@web.de writes: I am trying to write a simple shell loop in Python. You should investigate the ‘cmd’ module in the standard library URL:http://docs.python.org/library/cmd.html. My simple approach works fine - but the first output line after entering something

Re: How to make a reverse for loop in python?

2008-09-21 Thread Alex Snast
On Sep 21, 3:47 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sat, 20 Sep 2008 16:27:41 -0700, Alex Snast wrote: Another quick question please, is the List data structure just a dynamic array? If so how can you use static size array, linked list, AVL trees etcetera.

How to make a reverse for loop in python?

2008-09-20 Thread Alex Snast
Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make a reverse for loop in python?

2008-09-20 Thread Thoma
Alex Snast a écrit : Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) for (i = 0; i 10; i--) - for i in range(10): for (i = 10; i = 0; --i) - for i in range(10,-1,-1): Thoma

Re: How to make a reverse for loop in python?

2008-09-20 Thread Mensanator
On Sep 20, 11:16�am, Alex Snast [EMAIL PROTECTED] wrote: Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) for i in xrange(10,-1,-1): print i, 10 9 8 7 6 5 4 3 2 1 0 Note

Re: How to make a reverse for loop in python?

2008-09-20 Thread Duncan Booth
Alex Snast [EMAIL PROTECTED] wrote: Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) The exact equivalent would be: for i in range(10, -1, -1): print i except you

Re: How to make a reverse for loop in python?

2008-09-20 Thread Simon Brunning
2008/9/20 Alex Snast [EMAIL PROTECTED]: I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) for i in range(10, 0, -1): print i -- Cheers, Simon B. -- http://mail.python.org/mailman

Re: How to make a reverse for loop in python?

2008-09-20 Thread Fredrik Lundh
Alex Snast wrote: I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) use range with a negative step: for i in range(10-1, -1, -1): ... or just reverse the range: for i

Re: How to make a reverse for loop in python?

2008-09-20 Thread Gary Herron
Alex Snast wrote: Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) -- http://mail.python.org/mailman/listinfo/python-list What are you trying to loop through? If it's the contents

Re: How to make a reverse for loop in python?

2008-09-20 Thread Fredrik Lundh
Fredrik Lundh wrote: e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) use range with a negative step: for i in range(10-1, -1, -1): ... or just reverse the range: for i in reversed(range(10)): ... (and to include the 10 in the range, add one to

Re: How to make a reverse for loop in python?

2008-09-20 Thread Peter Otten
Gary Herron wrote: Or you can create a new reversed (copy of the original) list and iterate through it for item in reversed(L):   print item It's not a copy, it's a view: items = [1,2,3] r = reversed(items) items[:] = abc for item in r: print item ... c b a Peter --

Re: How to make a reverse for loop in python?

2008-09-20 Thread bearophileHUGS
Duncan Booth: e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) The exact equivalent would be: for i in range(10, -1, -1): print i I'd use xrange there. Anyway, I have always felt that Python syntax not easy to understand at first sight, expecially when you try to

Re: How to make a reverse for loop in python?

2008-09-20 Thread Alex Snast
On Sep 20, 8:13 pm, [EMAIL PROTECTED] wrote: Duncan Booth: e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) The exact equivalent would be:         for i in range(10, -1, -1): print i I'd use xrange there. Anyway, I have always felt that Python syntax not easy to

Re: How to make a reverse for loop in python?

2008-09-20 Thread Alex Snast
On Sep 20, 8:13 pm, [EMAIL PROTECTED] wrote: Duncan Booth: e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) The exact equivalent would be:         for i in range(10, -1, -1): print i I'd use xrange there. Anyway, I have always felt that Python syntax not easy to

Re: How to make a reverse for loop in python?

2008-09-20 Thread Christian Heimes
Alex Snast wrote: Another quick question please, is the List data structure just a dynamic array? If so how can you use static size array, linked list, AVL trees etcetera. You should treat Python lists as an opaque item. You shouldn't concern yourself with the implementation details. Python

Re: How to make a reverse for loop in python?

2008-09-20 Thread Gabriel Genellina
En Sat, 20 Sep 2008 20:27:41 -0300, Alex Snast [EMAIL PROTECTED] escribió: Another quick question please, is the List data structure just a dynamic array? If so how can you use static size array, linked list, AVL trees etcetera. Yes, lists are implemented as dynamic arrays (but you shouldn't

Re: How to make a reverse for loop in python?

2008-09-20 Thread Steven D'Aprano
On Sat, 20 Sep 2008 16:22:31 -0700, Alex Snast wrote: That's a lot of responses guys. Thanks a lot i think i got it. Another question, are there any pointers in python (or iterators) for when i use a data structure that doesn't support random access? That surely depends on the data

Re: How to make a reverse for loop in python?

2008-09-20 Thread bearophileHUGS
Christian Heimes: Unless you have specific needs for highly specialized data types, use lists. There's also the collections.deque for other related purposes. (I suggest people willing to look at some nice C code to read the sources of deque, Hettinger has created some refined code, very

Re: How to make a reverse for loop in python?

2008-09-20 Thread Steven D'Aprano
On Sat, 20 Sep 2008 16:27:41 -0700, Alex Snast wrote: Another quick question please, is the List data structure just a dynamic array? If so how can you use static size array, linked list, AVL trees etcetera. Before I answer your question, I should say that you can go a LONG way with just the

Re: How to make a reverse for loop in python?

2008-09-20 Thread Steven D'Aprano
On Sun, 21 Sep 2008 01:56:59 +0200, Christian Heimes wrote: Just *don't* try to abuse lists by creating fancy stuff e.g. linked lists. The memory overhead is going to kill your app. I agree with your advice not to abuse lists, but not for the reason you give. The memory overhead of a linked

Re: loop in python

2005-08-26 Thread travlr
I gotta say that as number cruncher, iteration in python is my biggest nightmare. I do what is possible with numpy, but element by element processing is a hassle. My programming experience is still pretty fresh at a year, so exotics as such are not in play yet. I also wish python looping/iterative

Re: loop in python

2005-08-25 Thread km
Hi all, What you are comparing is either IO times (the print loop program), where Perl beats C - which means that Perl's IO have been written at a very low level instead of relying on the stdlib's IO - i'd like to know what aspects are really coded in very low level for python ? regards,

Re: loop in python

2005-08-25 Thread James
I am going to be a bit blunt. Don't get offended. Also the first thing any newbie to python asks me is abt raw speed in comparison with similar languages like perl when i advocate python to perl. Judging by your other posts, you are a newbie yourself. You are not really in a position to

Re: loop in python

2005-08-25 Thread Sybren Stuvel
James enlightened us with: One does not compare speed when they use Perl/Python/Ruby/Tcl. They are all more or less in the same performance ball park. I don't want to offend you or anything, but doesn't the second sentence mean that someone DID do a speed comparison? Sybren -- The problem

Re: loop in python

2005-08-25 Thread Peter Hansen
Sybren Stuvel wrote: James enlightened us with: One does not compare speed when they use Perl/Python/Ruby/Tcl. They are all more or less in the same performance ball park. I don't want to offend you or anything, but doesn't the second sentence mean that someone DID do a speed comparison?

Re: loop in python

2005-08-25 Thread Sybren Stuvel
Peter Hansen enlightened us with: Yes, and has shown that they are in the same ballpark, and therefore one does not _need_ to compare speed any more. Ok. I'd worded it as there have been tests already, so there is no need to do your own, instead of one does not test. Sybren -- The problem

Re: loop in python

2005-08-25 Thread James
I don't want to offend you or anything, but doesn't the second sentence mean that someone DID do a speed comparison? I did provide Language Shootout link in the next paragraph of the post you referred to along with an obligatory caution about interpreting benchmarks. The Language Shootout is a

Re: loop in python

2005-08-24 Thread bruno modulix
Terry Hancock wrote: On Tuesday 23 August 2005 05:35 am, bruno modulix wrote: (snip) ot If you hope to be taken seriously, please abandon the sms-talk style here. /ot I think it's reasonably clear that neither poster hoped to be taken seriously. :-D Err... I guess that to be taken

Re: loop in python

2005-08-23 Thread km
If you want a fast language, try Holden. I've just invented it. Unfortunately it gets the answer to every problem wrong unless the answer is 42, but boy it runs quickly. The code for the whole interpreter (it's written in Python) follows: print 42 great ! u can use it for ur own

Re: loop in python

2005-08-23 Thread Randy Bush
computers are cheap. i am expensive. give me clear and maintainable code every time. randy -- http://mail.python.org/mailman/listinfo/python-list

Re: loop in python

2005-08-23 Thread rafi
km wrote: that this obsession reveals a certain inexperience. its neither obsession nor inexperience ... its just the requirement. i think less buggy code is not the main concern for all. Argh (choking) Then you are definitely a dangerous person! If your program is fast to give a false

Re: loop in python

2005-08-23 Thread bruno modulix
Terry Reedy wrote: Benjamin Niemann [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] (snip) In that case, you are interested in IO performance. The time spent handling the loop is not significant compared to the time spent executing the 'print' statement - which is a very complex

Re: loop in python

2005-08-23 Thread bruno modulix
Steve Holden wrote: (snip) If you want a fast language, try Holden. I've just invented it. Unfortunately it gets the answer to every problem wrong unless the answer is 42, but boy it runs quickly. The code for the whole interpreter (it's written in Python) follows: print 42 keyboard !

Re: loop in python

2005-08-23 Thread bruno modulix
km wrote: If you want a fast language, try Holden. I've just invented it. Unfortunately it gets the answer to every problem wrong unless the answer is 42, but boy it runs quickly. The code for the whole interpreter (it's written in Python) follows: print 42 great ! u can use it for ur

Re: loop in python

2005-08-23 Thread Fredrik Lundh
Steve Holden wrote: If you want a fast language, try Holden. I've just invented it. Unfortunately it gets the answer to every problem wrong unless the answer is 42, but boy it runs quickly. The code for the whole interpreter (it's written in Python) follows: print 42 Why are you looking

Re: loop in python

2005-08-23 Thread Terry Hancock
On Tuesday 23 August 2005 05:35 am, bruno modulix wrote: km wrote: If you want a fast language, try Holden. I've just invented it. Unfortunately it gets the answer to every problem wrong unless the answer is 42, but boy it runs quickly. The code for the whole interpreter (it's written in

loop in python

2005-08-22 Thread km
Hi all, Why is it that the implementation of empty loop so slow in python when compared to perl ? #i did this in python (v 1.5) for x in xrange(1000): print x # this took 0.017 seconds -- #similar code in perl (v 5.6): for $x (0..1000) { print $x; } # this took

Re: loop in python

2005-08-22 Thread Rick Wotnaz
km [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Hi all, Why is it that the implementation of empty loop so slow in python when compared to perl ? #i did this in python (v 1.5) for x in xrange(1000): print x # this took 0.017 seconds -- #similar

Re: loop in python

2005-08-22 Thread bruno modulix
km wrote: Hi all, Why is it that the implementation of empty loop so slow in python when compared to perl ? #i did this in python (v 1.5) Python 1.5.2 was released in april 1999. Current Python version is 2.4.1. Please consider upgrading - unless of course you just want to troll...

Re: loop in python

2005-08-22 Thread Daniel Dittmar
km wrote: Why is it that the implementation of empty loop so slow in python when compared to perl ? [...] Is python runtime slow at all aspects when compared to perl ? No I really wonder what makes python slower than perl ? It could be that the Perl compiler recognizes such a for loop

Re: loop in python

2005-08-22 Thread D H
km wrote: Hi all, Why is it that the implementation of empty loop so slow in python when compared to perl ? #i did this in python (v 1.5) for x in xrange(1000): print x # this took 0.017 seconds -- #similar code in perl (v 5.6): for $x (0..1000) {

Re: loop in python

2005-08-22 Thread km
Hi all, ya i am sorry i tried with an empty loop first and then one which emits a value as the snippet. I have tested it on my machine and now ... 1) perl (v 5.8) does the job in 0.005 seconds 2) but python (v 2.4.1) is horribly slow its 0.61 seconds. and using range() instead of xrange() in

Re: loop in python

2005-08-22 Thread Peter Hansen
km wrote: ya i am sorry i tried with an empty loop first and then one which emits a value as the snippet. I have tested it on my machine and now ... what more do i need to accept python is slow when it comes to loops concept ? You've sort of missed some of the points being made,

Re: loop in python

2005-08-22 Thread Terry Reedy
km [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] ya i am sorry i tried with an empty loop first and then one which emits a value as the snippet. I have tested it on my machine and now ... 1) perl (v 5.8) does the job in 0.005 seconds 2) but python (v 2.4.1) is horribly slow

Re: loop in python

2005-08-22 Thread km
Hi all, thing. If *all* your loops are going to do is print stuff, then you're doing the right thing with the version that emits values. ya most of the loops print values. know this). Since you haven't got any working code, it's not possible that you *need* whatever negligible speed

Re: loop in python

2005-08-22 Thread Bill Mill
They come out even in the computer language shootout: http://shootout.alioth.debian.org/benchmark.php?test=alllang=pythonsort=fullcpu (tied 8-8 in execution time, although perl wins 4-12 on memory consumption) Peace Bill Mill On 8/23/05, km [EMAIL PROTECTED] wrote: Hi all, thing. If

Re: loop in python

2005-08-22 Thread Steve Holden
km wrote: Hi all, Why is it that the implementation of empty loop so slow in python when compared to perl ? #i did this in python (v 1.5) for x in xrange(1000): print x # this took 0.017 seconds -- #similar code in perl (v 5.6): for $x (0..1000) {

Re: loop in python

2005-08-22 Thread Bill Mill
If you want a fast language, try Holden. I've just invented it. Unfortunately it gets the answer to every problem wrong unless the answer is 42, but boy it runs quickly. +1 QOTW (sometimes the zen master has to whack the student on the head) Peace Bill Mill bill.mill at gmail.com --

Re: loop in python

2005-08-22 Thread Bruno Desthuilliers
km a écrit : Hi all, ya i am sorry i tried with an empty loop first and then one which emits a value as the snippet. I have tested it on my machine and now ... 1) perl (v 5.8) does the job in 0.005 seconds 2) but python (v 2.4.1) is horribly slow its 0.61 seconds. and using range()

Re: loop in python

2005-08-22 Thread Peter Hansen
km wrote: thing. If *all* your loops are going to do is print stuff, then you're doing the right thing with the version that emits values. ya most of the loops print values. No, you missed my point. I said if *all* the loops are going to do is print stuff. In other words, no other

Re: loop in python

2005-08-22 Thread rafi
km wrote: Also the first thing any newbie to python asks me is abt raw speed in comparison with similar languages like perl when i advocate python to perl. Always the same chorus... Just tell the newbies that speed is not on their top list. If most of the world's computer programs where

Re: loop in python

2005-08-22 Thread Benjamin Niemann
km wrote: Hi all, thing. If *all* your loops are going to do is print stuff, then you're doing the right thing with the version that emits values. ya most of the loops print values. In that case, you are interested in IO performance. The time spent handling the loop is not significant

Re: loop in python

2005-08-22 Thread Terry Reedy
km [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I agree that python emphasizes on readability which i didnt see in many of the languages, but when the application concern is speed, does it mean that python is not yet ready? even most of the googling abt python Funny you should

Re: loop in python

2005-08-22 Thread Terry Reedy
Benjamin Niemann [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] km wrote: Hi all, thing. If *all* your loops are going to do is print stuff, then you're doing the right thing with the version that emits values. ya most of the loops print values. In that case, you are

Re: loop in python

2005-08-22 Thread Gregory Bond
km wrote: Is python runtime slow at all aspects when compared to perl ? And in addition to all that everyone else has said most of this is startup time. The python interpreter is a fair bit slower to start up (i.e. does much more at startup time) than the perl one: lenford$ time

Re: Proposal for adding Shallow Threads and a Main Loop to Python

2005-03-18 Thread Diez B. Roggisch
Hi, a few questions: A shallow thread is just a generator modified in the most obvious way possible. The yield statement is replaced with a waitfor expression. You give it the object you wish to wait for. Then when it's ready you get back a return value or an exception. These waitfor

Proposal for adding Shallow Threads and a Main Loop to Python

2005-03-17 Thread Rhamphoryncus
First a bit about myself. I've been programming in python several years now, and I've got several more years before that with C. I've got a lot of interest in the more theoretical stuff (language design, component architectures, etc). Of late my focus has been on concurrent operations (and on

Re: Proposal for adding Shallow Threads and a Main Loop to Python

2005-03-17 Thread Gary D. Duzan
In article [EMAIL PROTECTED], Rhamphoryncus [EMAIL PROTECTED] wrote: import mainloop, urllib def get_and_save(path): infile = waitfor urllib.urlopen(path, async=True) outfile = waitfor open(path.split('/')[-1], async=True) waitfor outfile.write(waitfor infile.read(async=True),

Re: Proposal for adding Shallow Threads and a Main Loop to Python

2005-03-17 Thread Rhamphoryncus
Gary D. Duzan wrote: A while back I tossed something together to deal with the same issue in terms of futures (or promises.) Here is roughly what the above code would look like with futures as I implemented them: snip This was all done using plain Python 1.5.2 in 80 lines of code,