if you are using linux, unix, os x:
pip install -U setuptools
pip install -U pip
pip install numpy
pip install scipy
pip install matplotlib
#pip install PySide
import ast | |
from timeit import repeat | |
import threading | |
from ctypes import pythonapi, c_void_p | |
import math | |
import numpy as np | |
try: | |
import numexpr as ne | |
nthreads = ne.ncores |
#!/usr/bin/env python | |
"""strip outputs from an IPython Notebook | |
Opens a notebook, strips its output, and writes the outputless version to the original file. | |
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS. | |
This does mostly the same thing as the `Clear All Output` command in the notebook UI. | |
LICENSE: Public Domain |
# +-----------------------------------------------------------------------------+ | |
# | Copyright (C) 2011-2015 | | |
# | Original by Marcel Loose (loose <at> astron.nl) 2011-2013 | | |
# | Modified by Chris Kerr (chris.kerr <at> mykolab.ch) 2013-2015 | | |
# | | | |
# | This program is free software; you can redistribute it and/or modify | | |
# | it under the terms of the GNU General Public License as published by | | |
# | the Free Software Foundation; either version 2 of the License, or | | |
# | (at your option) any later version. | | |
# | | |
if you are using linux, unix, os x:
pip install -U setuptools
pip install -U pip
pip install numpy
pip install scipy
pip install matplotlib
#pip install PySide
@echo off | |
:: Path to Sublime Text installation dir. | |
SET stPath=%~dp0sublime_text.exe | |
SET stPathOnly=%~dp0 | |
:: Key name for the registry entries. | |
SET UserEntry=Sublime Text | |
SET AdminEntry=Sublime Text As Admin | |
:: Context menu texts. | |
SET "UserMenuText=Open with Sublime(&-)" | |
SET "AdminMenuText=Open with Sublime As Admin(&+)" |
import os | |
import pyHook | |
import pythoncom | |
import threading | |
# Requires pyHook: http://sourceforge.net/apps/mediawiki/pyhook/ | |
# Requires pyWin32: http://sourceforge.net/projects/pywin32/ | |
# Kills the process if escape is pressed | |
class EscapeToKill(threading.Thread): |
#include <memory> | |
#include <random> | |
#include <chrono> | |
#include <algorithm> | |
#include <iostream> | |
#include <gflags/gflags.h> | |
#include <boost/chrono/chrono.hpp> | |
#include <boost/chrono/duration.hpp> | |
#include <boost/chrono/process_cpu_clocks.hpp> |
As of version 3.3, python includes the very promising concurrent.futures
module, with elegant context managers for running tasks concurrently. Thanks to the simple and consistent interface you can use both threads and processes with minimal effort.
For most CPU bound tasks - anything that is heavy number crunching - you want your program to use all the CPUs in your PC. The simplest way to get a CPU bound task to run in parallel is to use the ProcessPoolExecutor, which will create enough sub-processes to keep all your CPUs busy.
We use the context manager thusly:
with concurrent.futures.ProcessPoolExecutor() as executor:
Previous versions used homebrew to install the various versions. As suggested in the comments, it's better to use pyenv
instead. If you are looking for the previous version of this document, see the revision history.
$ brew update
$ brew install pyenv
$ pyenv install 3.5.0
$ pyenv install 3.4.3
$ pyenv install 3.3.6
$ pyenv install 3.2.6
$ pyenv install 2.7.10
$ pyenv install 2.6.9