This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ipython | |
%timeit l = [0,1,2,3,4,5,6,7,8,9] | |
%timeit l = (0,1,2,3,4,5,6,7,8,9) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ipython | |
%timeit l = range(10) | |
%timeit l = range(100000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%/usr/bin/time -lp python julia.py [~/source/hppython] | |
Length of x: 1000 | |
Total elements: 1000000 | |
@timefn: calculate_z_serial_purepython took 7.49427485466seconds | |
calculate_z_serial_purepython took 7.49432015419 sec | |
300.0 | |
real 8.54 | |
user 8.40 | |
sys 0.11 | |
144908288 maximum resident set size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%/usr/bin/time -p python julia.py [~/source/hppython] | |
Length of x: 1000 | |
Total elements: 1000000 | |
@timefn: calculate_z_serial_purepython took 7.09809708595seconds | |
calculate_z_serial_purepython took 7.09813809395 sec | |
300.0 | |
real 8.06 | |
user 7.95 | |
sys 0.09 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%timeit your_function() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -m timeit -n 5 -r 5 -s "imprort julia" "julia.your_function()" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start_time = time.time() | |
~何か処理~ | |
end_time = time.time() | |
duration = end_time - start_time | |
print duration | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search_1st(haystack, needle): | |
for item in haystack: | |
if item == needle: | |
return True | |
return False | |
def search_2nd(haystack, needle): | |
val = False | |
for item in haystack: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import sys | |
def check_prime(number): | |
sqrt_number = math.sqrt(number) | |
number_float = float(number) | |
for i in xrange(2, int(sqrt_number)+1): | |
if (number_float / i).is_integer(): | |
return False | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/ | |
notice: change contlib directory. | |
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/tools/ -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/deep/tools/opencv_contrib/modules -D BUILD_EXAMPLES=O -D WITH_FFMPEG=OFF -D WITH_CUDA=OFF .. | |
cd /usr/local/lib/python2.7/site-packages | |
ln -s /usr/tools/lib/python2.7/dist-packages/cv2.so ./ | |
add pythonpath | |
/usr/local/lib/python2.7/site-packages |