Hi,
Next Sunday I am going to run the London Marathon to raise money for Treehouse:
an educational charity for children with autism that is very close to
my heart.
Autism is a condition which my cousin James and hundreds of thousands of other
people in the UK suffer from. It impairs their abili
Hi.
Thanks for everyone answers. It's true, hehe, it's not a benchmark
or anything like that. I hadn't taken into account compiler
optimizations, but I have learnt a lot in this thread.
About the Java code, Bigints are used.
ark
___
Tutor maillist -
"Lie Ryan" wrote
A friend of mine suggested me to do the next experiment in python and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
Are you sure you're not causing Java to overflow here?
> result = sum(range(10))
>
> although it still took 10 minutes on my PC.
Did you mean to say "minutes" or rather "seconds" here? And did you
really mean to use "range" or rather "xrange" (or "range" in Py3)?
Yes, minutes and in Python 3.
And on a 2.8GHz 2 core CPU with 2G RAM
su
"Steven D'Aprano" wrote
(We can of course do some fancy math to speed this particular
sum up since the result for any power of ten has a common pattern,
but I wouldn't expect the compiler optimiser to be that clever)
No fancy maths needed,
The sum of 1,2,3,4,...,N is given by a simple for
ALAN GAULD wrote:
The precalculation optimisations are
taking place. If you pass it an argument to use for the upper limit of the
sequence the calculation time shoots up.
I'm still confused about when the addition takes place.
Surely the compiler has to do the addition, so it should
On 04/16/10 16:50, Ark wrote:
> Hi everyone.
> A friend of mine suggested me to do the next experiment in python and Java.
>
> It's a simple program to sum all the numbers from 0 to 10.
>
> result = i = 0
> while i < 10:
> result += i
> i += 1
> print result
>
Are you su
Steven D'Aprano, 16.04.2010 12:00:
On Fri, 16 Apr 2010 06:29:40 pm Alan Gauld wrote:
"Stefan Behnel" wrote
import cython
@cython.locals(result=cython.longlong, i=cython.longlong)
def add():
result = 0
for i in xrange(10):
result += i
On Fri, 16 Apr 2010 06:25:54 pm Stefan Behnel wrote:
> Alan Gauld, 16.04.2010 10:09:
> > Even the built in sum() will be faster than a while loop:
> >
> > result = sum(range(10))
> >
> > although it still took 10 minutes on my PC.
>
> Did you mean to say "minutes" or rather "seconds" here?
On Fri, 16 Apr 2010 06:29:40 pm Alan Gauld wrote:
> "Stefan Behnel" wrote
>
> > import cython
> >
> > @cython.locals(result=cython.longlong, i=cython.longlong)
> > def add():
> > result = 0
> > for i in xrange(10):
> > result += i
> > return
Greetings,
I'm doing a lot of email processing at the moment. I put
together some basic code from within Outlook to open my
default inbox, filter email records based on text in the
Subject field, then parse the body, finally send the output
to a text file. This is simple stuff but very useful
> The precalculation optimisations are
> taking place. If you pass it an argument to use for the upper limit of the
> sequence the calculation time shoots up.
I'm still confused about when the addition takes place.
Surely the compiler has to do the addition, so it should be slower?
I assume
Ray Parrish wrote:
Hello,
I am trying to figure out how to send cookie data with an httplib
request command. Here is what the doc says -
request( method, url[, body[, headers]])
This will send a request to the server using the HTTP request
method method and the selector url. If the b
Alan Gauld, 16.04.2010 10:29:
"Stefan Behnel" wrote
import cython
@cython.locals(result=cython.longlong, i=cython.longlong)
def add():
result = 0
for i in xrange(10):
result += i
return result
print add()
This runs in less than half a second on my machine, includin
Peter Meagher wrote:
GREETINGS,
THIS EMAIL WOULD INDICATE THAT I AM ON THE SUBSCRIPTION
LIST.
HOWEVER, I GOT ANOTHER EMAIL, THAT CAME IN AT PRECISELY THE
SAME TIME AS THE ORIGINAL MESSAGE THAT I AM FORWARDING YOU.
THAT INDICATES THAT THERE WAS AN ISSUE ADDING ME TO THE
LIST. I'VE PASTED IT IN T
Dave Angel wrote:
Christian Witts wrote:
Ark wrote:
Hi everyone.
A friend of mine suggested me to do the next experiment in python
and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
The
Alan Gauld wrote:
"Stefan Behnel" wrote
import cython
@cython.locals(result=cython.longlong, i=cython.longlong)
def add():
result = 0
for i in xrange(10):
result += i
return result
print add()
This runs in less than half a second on
Stefan Behnel, 16.04.2010 09:38:
A compiler for a statically compiled language can see that the
above loop yields a constant result, so it can calculate the result in
advance (or at least reduce the loop overhead for the calculation)
instead of generating code for the loop as it stands.
That re
Christian Witts wrote:
Ark wrote:
Hi everyone.
A friend of mine suggested me to do the next experiment in python and
Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
The time for this calc
"Stefan Behnel" wrote
import cython
@cython.locals(result=cython.longlong, i=cython.longlong)
def add():
result = 0
for i in xrange(10):
result += i
return result
print add()
This runs in less than half a second on my machine, inclu
Alan Gauld, 16.04.2010 10:09:
Even the built in sum() will be faster than a while loop:
result = sum(range(10))
although it still took 10 minutes on my PC.
Did you mean to say "minutes" or rather "seconds" here? And did you really
mean to use "range" or rather "xrange" (or "range" in
"Ark" wrote
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
The time for this calculations was huge. It took a long time to give
the result. But, the corresponding program in Java takes less than
GREETINGS,
THIS EMAIL WOULD INDICATE THAT I AM ON THE SUBSCRIPTION
LIST.
HOWEVER, I GOT ANOTHER EMAIL, THAT CAME IN AT PRECISELY THE
SAME TIME AS THE ORIGINAL MESSAGE THAT I AM FORWARDING YOU.
THAT INDICATES THAT THERE WAS AN ISSUE ADDING ME TO THE
LIST. I'VE PASTED IT IN THE BLOCK OF TEXT BELOW,
Ark wrote:
Hi everyone.
A friend of mine suggested me to do the next experiment in python and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i < 10:
result += i
i += 1
print result
The time for this calculations was huge. It took
Ark, 16.04.2010 08:50:
A friend of mine suggested me to do the next experiment in python and Java.
It's a simple program to sum all the numbers from 0 to 10.
result = i = 0
while i< 10:
result += i
i += 1
print result
I hope you are aware that this is a) a very lous
25 matches
Mail list logo