-
Notifications
You must be signed in to change notification settings - Fork 261
Closed
Description
Is there a way to iterate through a SortedDict without causing memory allocation? (I'm using a SortedDict in an inner loop, and most of the time is spent in the next function used for iterating.)
Here is a small example:
using DataStructures
function bench()
dict = SortedDict(["New York" => 1788, "Illinois" => 1818])
clear_malloc_data()
@time for trial in 1:10000000
counter = 0
for item in dict
counter += 1 # dummy operation for example purposes only
end
end
end
bench()
I'm running Julia 0.3.4 with --track-allocation=all. I'm seeing allocations on the for item in dict line in my script, and in the nexthelper function in sortedDict.jl. It seems that 320 bytes are allocated at every iteration.
If you think this is doable and point me in the right direction, I will consider contributing a pull request :)
Metadata
Metadata
Assignees
Labels
No labels