Skip to content

Commit a35c88b

Browse files
committed
By default, use the real number of physical cores
1 parent e2edf62 commit a35c88b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pandarallel/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import dill
1111
import pandas as pd
12+
import psutil
1213
from pandas.core.groupby import DataFrameGroupBy as PandaDataFrameGroupBy
1314
from pandas.core.window.expanding import ExpandingGroupby as PandasExpandingGroupby
1415
from pandas.core.window.rolling import RollingGroupby as PandasRollingGroupby
@@ -32,7 +33,7 @@
3233
MEMORY_FS_ROOT = "/dev/shm"
3334

3435
# By default, Pandarallel use all available CPUs
35-
NB_WORKERS = max(CONTEXT.cpu_count() // 2, 1)
36+
NB_PHYSICAL_CORES = psutil.cpu_count(logical=False)
3637

3738
# Prefix and suffix for files used with Memory File System
3839
PREFIX = "pandarallel"
@@ -441,7 +442,7 @@ class pandarallel:
441442
def initialize(
442443
cls,
443444
shm_size_mb=None,
444-
nb_workers=NB_WORKERS,
445+
nb_workers=NB_PHYSICAL_CORES,
445446
progress_bar=False,
446447
verbose=2,
447448
use_memory_fs: Optional[bool] = None,

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ packages = find:
2222
install_requires =
2323
dill >= 0.3.1
2424
pandas >= 1
25+
psutil
2526

2627
[options.packages.find]
2728
exclude =

0 commit comments

Comments
 (0)