From d74b1be90469643af49247422cb07b3b8121a293 Mon Sep 17 00:00:00 2001 From: Frank Fineis Date: Mon, 15 Feb 2021 09:04:09 -0600 Subject: [PATCH] reuse len(parts) as n_parts (#3985) --- python-package/lightgbm/dask.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python-package/lightgbm/dask.py b/python-package/lightgbm/dask.py index 3a2778d103e5..cccf6b97d2b5 100644 --- a/python-package/lightgbm/dask.py +++ b/python-package/lightgbm/dask.py @@ -284,15 +284,16 @@ def _train( data_parts = _split_to_parts(data=data, is_matrix=True) label_parts = _split_to_parts(data=label, is_matrix=False) parts = [{'data': x, 'label': y} for (x, y) in zip(data_parts, label_parts)] + n_parts = len(parts) if sample_weight is not None: weight_parts = _split_to_parts(data=sample_weight, is_matrix=False) - for i in range(len(parts)): + for i in range(n_parts): parts[i]['weight'] = weight_parts[i] if group is not None: group_parts = _split_to_parts(data=group, is_matrix=False) - for i in range(len(parts)): + for i in range(n_parts): parts[i]['group'] = group_parts[i] # Start computation in the background