Skip to content

Commit

Permalink
Sped up Cython compile speed by ensuring both the cython part and c++…
Browse files Browse the repository at this point in the history
… part are parallelized by number of logical CPU cores.
  • Loading branch information
martinkou committed May 9, 2019
1 parent 601d002 commit 597123f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions compile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash

python setup.py build_ext --inplace \
-j $(python -c "import os; print(os.cpu_count() or 8, end='')")
python setup.py build_ext --inplace
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
import os
import subprocess
import sys

if os.name == "posix":
os_name = subprocess.check_output("uname").decode("utf8")
Expand All @@ -15,6 +16,7 @@


def main():
cpu_count = os.cpu_count() or 8
version = "20190508"
packages = [
"wings",
Expand Down Expand Up @@ -100,6 +102,9 @@ def main():
]
package_data["wings"].append("cpp/*.cpp")

if sys.argv[1] == "build_ext":
sys.argv.append(f"--parallel={cpu_count}")

setup(name="hummingbot",
version=version,
description="CoinAlpha Hummingbot",
Expand All @@ -113,7 +118,7 @@ def main():
ext_modules=cythonize([
"hummingbot/**/*.pyx",
"wings/**/*.pyx",
], language="c++", language_level=3),
], language="c++", language_level=3, nthreads=cpu_count),
include_dirs=[
np.get_include(),
],
Expand Down

0 comments on commit 597123f

Please sign in to comment.