Skip to content

List performance improvent by Union-typed tail #682

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tisztamo
Copy link

Just found this non-breaking alternative to #681 with similar (somewhat worse, but still 10x+ iteration) performance.

  | | |_| | | | (_| |  |  Version 1.5.1 (2020-08-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using DataStructures
       println("Creation:")
       @btime nil()
       @btime list(1)
       @btime list(1,2,3,4,5,6,7)
       const lshort = list(1,2,3,4,5,6,7)
       @btime list([i for i=1:1000]...)
       const llong = list([i for i=1:1000]...)
       println("Iteration:")
       @btime sum(lshort)
       @btime sum(llong)
       println("Reverse:")
       @btime reverse(lshort)
       @btime reverse(llong)
       println("Map:")
       @btime map(x->2x, lshort)
       @btime map(x->2x, llong)
       println("Copy:")
       @btime copy(lshort)
       @btime copy(llong);
Creation:
  3.405 ns (1 allocation: 8 bytes)
  8.175 ns (2 allocations: 40 bytes)
  29.328 ns (8 allocations: 232 bytes)
  15.242 μs (1492 allocations: 54.77 KiB)
Iteration:
  3.910 ns (0 allocations: 0 bytes)
  1.363 μs (0 allocations: 0 bytes)
Reverse:
  33.955 ns (8 allocations: 232 bytes)
  3.955 μs (1001 allocations: 31.26 KiB)
Map:
  68.279 ns (16 allocations: 464 bytes)
  8.354 μs (2002 allocations: 62.52 KiB)
Copy:
  64.018 ns (16 allocations: 464 bytes)
  8.082 μs (2002 allocations: 62.52 KiB)

@oxinabox
Copy link
Member

Currently we are stongly considering deprecating DataStructure.jl's LinkedLists in favour of FunctionalCollection's equivelent (plist).

You might want to make this PR over there:
https://github.com/JuliaCollections/FunctionalCollections.jl/blob/2dd9b36fd6e637c866011363ba6b7097345d0df4/src/PersistentList.jl#L8

@tisztamo
Copy link
Author

I will do that, thanks for pointing out!

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.

2 participants