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.

full works on lists but with very bad performance

See original GitHub issue

When you pass a python list to full, it actually works as expected but with bad performance. The documentation says that only a scalar is accepted, but because it does the right thing, it’s very easy for people to end up with code like this that’s correct but inefficient.

import numpy
x = numpy.full(100, range(100))

The reason it’s inefficient is because the source looks like this:

    if dtype is None:
        dtype = array(fill_value).dtype
    a = empty(shape, dtype, order)
    multiarray.copyto(a, fill_value, casting='unsafe')
    return a

If the dtype is not specified, the branch actually creates a copy of the whole array, throws it away, and then does it again.

I would suggest either explicitly supporting this use case, and improving performance and docs to match. Or, try to do some kind of basic check to reject this input as unacceptable.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ghostcommented, Jun 20, 2020

Thanks all for the help, @eric-wieser I just created a new branch and did the changes again since it was such a small change.

1reaction
ghostcommented, Jun 11, 2020

Ah thank you! Just pulled the trigger on that. Apologies for the hold up, I’m new to this workflow and thought I was done after simply doing a commit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

11 Tips for Talking About Poor Performance - SHRM
Difficult conversations sometimes are inevitable. Don't make them harder than they have to be.
Read more >
7 Causes of Poor Employee Performance - LinkedIn
If an employee seems bored or burned out, it's the manager's job to try to help reenergize him. Being burned out is not...
Read more >
What to Do After a Bad Performance Review
Here's how to bounce back from a negative review. Reflect before you react. It's tempting to get angry or defensive, especially if you're ......
Read more >
How To Deal With Poor Employee Performance
The first is to understand the reason and judge if they're genuine or not. Even if they're not, do not let the other...
Read more >
Performance of Arrays vs. Lists - Stack Overflow
A prepend operation is just an insert at 0. It's the worst case insert in terms of performance, so if insert is slow,...
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