Re: list comparison vs integer comparison, which is more efficient?

2015-01-05 Thread Jonas Wielicki
On 04.01.2015 13:17, austin aigbe wrote > Hi Terry, > > No difference between the int and list comparison in terms of the number of > calls(24) and time (0.004s). Main part is the repeated call to sqrt(). > > However, it took a shorter time (0.004s) with 24 function calls than your > code (0.00

Re: list comparison vs integer comparison, which is more efficient?

2015-01-04 Thread Mark Lawrence
On 04/01/2015 12:22, Christian Gollwitzer wrote: Am 04.01.15 um 13:17 schrieb austin aigbe: However, it took a shorter time (0.004s) with 24 function calls than your code (0.005s) which took just 13 function calls to execute. Why is this? These times are way too short for conclusive results

Re: list comparison vs integer comparison, which is more efficient?

2015-01-04 Thread Chris Angelico
On Sun, Jan 4, 2015 at 11:17 PM, austin aigbe wrote: > However, it took a shorter time (0.004s) with 24 function calls than your > code (0.005s) which took just 13 function calls to execute. > > Why is this? That looks to me like noise in your stats. One ULP in timing stats? Not something to bas

Re: list comparison vs integer comparison, which is more efficient?

2015-01-04 Thread Christian Gollwitzer
Am 04.01.15 um 13:17 schrieb austin aigbe: However, it took a shorter time (0.004s) with 24 function calls than your code (0.005s) which took just 13 function calls to execute. Why is this? These times are way too short for conclusive results. Typically, the OS timer operates with a millise

Re: list comparison vs integer comparison, which is more efficient?

2015-01-04 Thread austin aigbe
gt; For the qpsk, 16qam and 64qam modulation I would like to know which is > > > more efficient to use, between an integer comparison and a list > > > comparison: > > > > > > Integer comparison: bit_pair as an integer value before comparison > > > >

Re: list comparison vs integer comparison, which is more efficient?

2015-01-04 Thread austin aigbe
On Sunday, January 4, 2015 8:12:10 AM UTC+1, Terry Reedy wrote: > On 1/3/2015 6:19 PM, austin aigbe wrote: > > > I am currently implementing the LTE physical layer in Python (ver 2.7.7). > > For the qpsk, 16qam and 64qam modulation I would like to know which is more > > e

Re: list comparison vs integer comparison, which is more efficient?

2015-01-03 Thread Terry Reedy
On 1/3/2015 6:19 PM, austin aigbe wrote: I am currently implementing the LTE physical layer in Python (ver 2.7.7). For the qpsk, 16qam and 64qam modulation I would like to know which is more efficient to use, between an integer comparison and a list comparison: Integer comparison: bit_pair as

Re: list comparison vs integer comparison, which is more efficient?

2015-01-03 Thread Chris Angelico
On Sun, Jan 4, 2015 at 10:19 AM, austin aigbe wrote: > I would like to know which is more efficient to use, between an integer > comparison and a list comparison: You can test them with the timeit module, but my personal suspicion is that any difference between them will be utter

list comparison vs integer comparison, which is more efficient?

2015-01-03 Thread austin aigbe
Hi, I am currently implementing the LTE physical layer in Python (ver 2.7.7). For the qpsk, 16qam and 64qam modulation I would like to know which is more efficient to use, between an integer comparison and a list comparison: Integer comparison: bit_pair as an integer value before comparison

Re: Which is More Efficient?

2006-05-19 Thread John Machin
Dustan wrote: > Fredrik Lundh wrote: >> are you for real? > And what exactly is that supposed to mean? The obscurity in that communication is probably caused by the instance of the effbot with which you have been corresponding having been invoked with mildmannered=True -- apparently this is not t

Re: Which is More Efficient?

2006-05-19 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > The task manager says "CPU Usage: 100%" when the program is running, > > and only when the program is running. > > > > Efficiency is a measure of 2 things: CPU usage and time. If you measure > > just time, you're not necessarily getting the efficiency. >

Re: Which is More Efficient?

2006-05-19 Thread Fredrik Lundh
Dustan wrote: > The task manager says "CPU Usage: 100%" when the program is running, > and only when the program is running. > > Efficiency is a measure of 2 things: CPU usage and time. If you measure > just time, you're not necessarily getting the efficiency. are you for real? -- http://m

Re: Which is More Efficient?

2006-05-19 Thread Max Erickson
"Dustan" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > > The task manager says "CPU Usage: 100%" when the program is > running, and only when the program is running. > > Efficiency is a measure of 2 things: CPU usage and time. If you > measure just time, you're not necessarily getting

Re: Which is More Efficient?

2006-05-19 Thread Dustan
Dustan wrote: > Fredrik Lundh wrote: > > Dustan wrote: > > > > > Obviously it takes a geek to know you have to time it, as opposed to > > > any other task you could be talking about. > > > > wasn't the original question "my program uses a lot of CPU, and I want > > to make it more efficient" ? wha

Re: Which is More Efficient?

2006-05-19 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > Obviously it takes a geek to know you have to time it, as opposed to > > any other task you could be talking about. > > wasn't the original question "my program uses a lot of CPU, and I want > to make it more efficient" ? what does "a lot of CPU" and "mo

Re: Which is More Efficient?

2006-05-18 Thread Fredrik Lundh
Dustan wrote: > Obviously it takes a geek to know you have to time it, as opposed to > any other task you could be talking about. wasn't the original question "my program uses a lot of CPU, and I want to make it more efficient" ? what does "a lot of CPU" and "more efficient" mean to you, and h

Re: Which is More Efficient?

2006-05-18 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > >> 2. Measure it. > > > > Tell me how and I will; I'm not nearly that much of a geek > > unfortunately. > > do you have to be a geek to be able to measure how much time > something takes? Obviously it takes a geek to know you have to time it, as opposed to

Re: Which is More Efficient?

2006-05-18 Thread Fredrik Lundh
Dustan wrote: >> 2. Measure it. > > Tell me how and I will; I'm not nearly that much of a geek > unfortunately. do you have to be a geek to be able to measure how much time something takes? -- http://mail.python.org/mailman/listinfo/python-list

Re: Which is More Efficient?

2006-05-18 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > I have a program that uses up a lot of CPU and want to make it is > > efficient as possible with what I have to work with it. So which of the > > following would be more efficient, knowing that l is a list and size is > > a number? > > > > l=l[:size] > >

Re: Which is More Efficient?

2006-05-18 Thread Ben Finney
"Dustan" <[EMAIL PROTECTED]> writes: > John Machin wrote: > > 2. Measure it. > > Tell me how and I will; I'm not nearly that much of a geek > unfortunately. You've already been told. Here it is again: http://docs.python.org/lib/profile.html> -- \ "I don't know half of you half as we

Re: Which is More Efficient?

2006-05-18 Thread Dustan
John Machin wrote: > 1. Think about it. The first case will make a new list and copy "size" > *objects. When the assignment happens, the old list has its reference > count decremented. Not very memory-friendly. The second case merely > truncates the existing list in situ. Bit hard to imagine how t

Re: Which is More Efficient?

2006-05-18 Thread John Machin
1. Think about it. The first case will make a new list and copy "size" *objects. When the assignment happens, the old list has its reference count decremented. Not very memory-friendly. The second case merely truncates the existing list in situ. Bit hard to imagine how the first case could ever be

Re: Which is More Efficient?

2006-05-18 Thread Fredrik Lundh
Dustan wrote: > I have a program that uses up a lot of CPU and want to make it is > efficient as possible with what I have to work with it. So which of the > following would be more efficient, knowing that l is a list and size is > a number? > > l=l[:size] > del l[size:] since you have the progr

Re: Which is More Efficient?

2006-05-18 Thread Ben Finney
"Dustan" <[EMAIL PROTECTED]> writes: > I have a program that uses up a lot of CPU and want to make it is > efficient as possible with what I have to work with it. Profile your program and find the precise parts that are the slowest. Attempting to optimise before that is a waste of your time. > S

Re: Which is More Efficient?

2006-05-18 Thread dan . gass
Measure it and find out. Sounds like a little investment in your time learning how to measure performance may pay dividends for you. -- http://mail.python.org/mailman/listinfo/python-list

Which is More Efficient?

2006-05-18 Thread Dustan
I have a program that uses up a lot of CPU and want to make it is efficient as possible with what I have to work with it. So which of the following would be more efficient, knowing that l is a list and size is a number? l=l[:size] del l[size:] If it makes a difference, everything in the list is m