Polars 'POLARS_MAX_THREADS' doesn't actually work, although it does create POLARS_MAX_THREADS number of threads at beginning, but after i do some calculation, the number of threads it uses boost a lot.
import os
os.environ['POLARS_MAX_THREADS'] = '4'
from time import sleep
import psutil
import polars as pl
print(pl.threadpool_size())
df = pl.DataFrame({'a': [1,2,3],
'b': [4,5,6]})
df = df + 1
print(pl.threadpool_size())
print('Num threads before: {}'.format(psutil.Process().num_threads()))
sleep(1000)
The code get
4
4
Num threads before: 149
The threads it use actually equals to the number of cores on the machine.