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

lists:reverse/1 vs. lists:reverse/2 performance #8488

Closed
TD5 opened this issue May 16, 2024 · 1 comment
Closed

lists:reverse/1 vs. lists:reverse/2 performance #8488

TD5 opened this issue May 16, 2024 · 1 comment
Labels
bug Issue is reported as a bug

Comments

@TD5
Copy link
Contributor

TD5 commented May 16, 2024

Describe the bug

lists:reverse(List,[]) is ~50% faster than lists:reverse(List) for big lists, and about the same for tiny lists, according to my benchmarks.

Unlike lists:reverse/1, lists:reverse/2 is implemented in a BIF, and is documented as follows:

Returns a list with the elements in List1 in reverse order, with tail Tail
appended.

Example:

$ lists:reverse([1, 2, 3, 4], [a, b, c]).
[4,3,2,1,a,b,c]

Expected behaviour
Comparable performance between the two.

@TD5 TD5 added the bug Issue is reported as a bug label May 16, 2024
@TD5
Copy link
Contributor Author

TD5 commented May 16, 2024

Hmm, after rerunning my benchmarks with more samples, I can't reproduce this, so I guess it was just noise.

@TD5 TD5 closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug
Projects
None yet
Development

No branches or pull requests

1 participant