question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't use `numpy.append`

See original GitHub issue

In some parts of Optuna, numpy.append is used. However, dynamically changing numpy.ndarray is slow, so for performance, it is better to append as a list first, and then cast with numpy.asarray. We are looking for someone to list and fix the parts where numpy.append is used.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nzw0301commented, Mar 10, 2021

@HideakiImamura I think that this issue can be closed.

@jeromepatel Please do not worry that your kindful proposal was not accepted 😢

1reaction
hvycommented, Feb 26, 2021

I suppose you’re referring to code that repeatedly calls numpy.append inside a loop. Allocating new arrays in each iteration is inefficient and I agree that such code can be optimized. Just leaving a note that this can be done in different ways. For instance, if you know the loop size, you could perform a single allocation prior to the loop.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python numpy array append not working in .py file, but ...
1. According to an answer of this question , I found out that it was because I wasn't using a 'copy' of the...
Read more >
How to use the Numpy append function
The NumPy append function enables you to append new values to an existing NumPy array. Other tutorials here at Sharp Sight have shown...
Read more >
numpy.append(): How to Add Elements to a NumPy Array
To append elements into a NumPy array, use a separate numpy.append(arr, elements) function. This returns a new array with appended elements.
Read more >
Is it better to use np.append() or list.append()?
Actually, numpy append leads to copy actions so you would be much better off to first create a list in “"normal Python”. Even...
Read more >
numpy.append() in Python
Python numpy append() function is used to merge two arrays. This function returns a new array and the original array remains unchanged.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found