Popular recipes tagged "fast"http://code.activestate.com/recipes/tags/fast/2010-08-13T18:28:00-07:00ActiveState Code RecipesFastest way to list all primes below N in python (Python)
2010-07-27T01:57:20-07:00robert.william.hankshttp://code.activestate.com/recipes/users/4174481/http://code.activestate.com/recipes/577331-fastest-way-to-list-all-primes-below-n-in-python/
<p style="color: grey">
Python
recipe 577331
by <a href="/recipes/users/4174481/">robert.william.hanks</a>
(<a href="/recipes/tags/fast/">fast</a>, <a href="/recipes/tags/fastest/">fastest</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/primes/">primes</a>, <a href="/recipes/tags/python/">python</a>).
Revision 6.
</p>
<p>I was looking for a fast way to list all primes below n,
so far i came up to this with the numpy solution the fastest.
It does primes up to 10e6 in 15ms in my old machine,
and it is capable of reaching 10e9. </p>
A fast & memory-wise prime number generator up to N (Python)
2010-08-13T18:28:00-07:00robert.william.hankshttp://code.activestate.com/recipes/users/4174481/http://code.activestate.com/recipes/577357-a-fast-memory-wise-prime-number-generator-up-to-n/
<p style="color: grey">
Python
recipe 577357
by <a href="/recipes/users/4174481/">robert.william.hanks</a>
(<a href="/recipes/tags/fast/">fast</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/primes/">primes</a>, <a href="/recipes/tags/prime_generator/">prime_generator</a>, <a href="/recipes/tags/prime_number/">prime_number</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>Using python 2.6 & numpy.
This code was first posted <a href="http://stackoverflow.com/questions/2897297/speed-up-bitstring-bit-operations-in-python/2908512#2908512">here</a></p>
Python Vectors (Python)
2009-11-25T04:50:10-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/576908-python-vectors/
<p style="color: grey">
Python
recipe 576908
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/fast/">fast</a>, <a href="/recipes/tags/point/">point</a>, <a href="/recipes/tags/vector/">vector</a>).
Revision 3.
</p>
<p>This recipe implements vectors in pure Python and does not use "C" for speed enhancements. As a result, much effort has gone towards optimizing the instructions for the class methods. There are a few things that have yet to be improved, but it is being posted as an RFC. Comments on the structure, method names, and coding technique are requested for change. Once this code is standardized, work may commence on writing Vector3, Vector4, and VectorX. Please note that there is a difference between the "direction" and "degrees" properties.</p>