Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] replace numpy.zeros with numpy.empty for the speedup #4410

Merged
merged 1 commit into from
Jun 27, 2021

Conversation

StrikerRUS
Copy link
Collaborator

empty, unlike zeros, does not set the array values to zero, and may therefore be marginally faster. On the other hand, it requires the user to manually set all the values in the array, and should be used with caution.
https://numpy.org/doc/stable/reference/generated/numpy.empty.html

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me!

I checked the blame and np.empty() has been a part of numpy for 15 years, so I don't think this introduces any compatibility problems: https://github.com/numpy/numpy/blame/623bc1fae1d47df24e7f1e29321d0c0ba2771ce0/numpy/matlib.py

@StrikerRUS StrikerRUS merged commit 45ac271 into master Jun 27, 2021
@StrikerRUS StrikerRUS deleted the numpy_speedup branch June 27, 2021 12:58
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants