26

Re: Re: problems from the headhunter

Hello, Kodt, you wrote: About  I do not know. run (eratosphen) # 0.692999839783 run (populate1) # 4.71099996567 run (populate2) # 3.72500014305 This slow sieve, here hardly faster: def eratosphen2 (n): isc = [False] * (n+1) for x in xrange (3, n+1,2): if isc [x]: continue if n / x <x: break for y in xrange (x*x, n+1, x+x): isc [y] = True return [2] + [x for x in xrange (3, n+1,2) if not isc [x]] sifting of even numbers, sifting of already sifted small numbers, and empty sifting on too big prime numbers Is thrown out. At me (on ) for N=2400000 it is laid down in 0.15 seconds, for N=24000000 - in 2 seconds, at you it should turn out 0.17 and 2.3 accordingly. Still not one hundred, but already hardly is better Still it is possible to accelerate, if under even numbers not to select storage, plus to alter an array with  on the numerical: def eratosphen3 (n): m = (n+1)//2 isc = [0] *m for x in xrange (1, m): if isc [x]: continue p, b = x + x + 1, (x + x) * (x + 1) if m <= b: break for y in xrange (b, m, p): isc [y] = 1 return [2] + [x+x+1 for x in xrange (1, m) if not isc [x]] So at me it was accelerated till 0.12 and 1.66 accordingly.

27

Re: Re: problems from the headhunter

28

Re: Re: problems from the headhunter

Hello, Kodt, you wrote: Generally the sorcerer! In 4 times concerning an initial sieve. 4 is a little. It only small slit-type optimization. In the python the hundred part if from it something , for the account of knowledge of its depths, it is possible to be accelerated still probably is put a minimum. Once I tortured this  on , on a python for on  for a long time there was not killed record of 0 seconds. There except  it was possible to be perverted for the account of nuances: ` expr ` there is faster, than str (expr), where in expr a small formula for integer calculation; tabulation faster several gaps for are one character, and permanently all re-reads the interpreter, well and to that similar. I suspect that a theoretical difference in 100 times it did not turn out, in particular, because of slow  sheets though it  even more slowly,  did not try. So what  at you turned out?