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

Fix pull() to change the list instead of creating a new one #5

Merged
merged 1 commit into from
Jul 25, 2014

Conversation

nathancahill
Copy link
Contributor

In Lodash, _.pull() can be called on an array without using the returned value, see the example here: http://lodash.com/docs#pull

Not as short, but more consistent with Lodash.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 0632575 on nathancahill:master into 157775c on dgilland:master.

try:
array.remove(value)
except ValueError:
break
Copy link
Owner

Choose a reason for hiding this comment

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

You can eliminate the try/except and break by doing this:

while array.count(value) > 0:
    array.remove(value)

Copy link
Owner

Choose a reason for hiding this comment

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

Not sure on the performance difference between these two methods though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your method is considerably faster. timeit clocks try/except at 4.41, and while at 3.12.

dgilland added a commit that referenced this pull request Jul 25, 2014
Fix pull() to change the list instead of creating a new one
@dgilland dgilland merged commit 2bc2a60 into dgilland:master Jul 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants