JuliaCollections / JuliaCollections/DataStructures.jl

Support @inbounds for queue (and other data structures)

Open
#586 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
745
Forks
261
PR merge metrics
No merged PRs in 30d

Description

I saw that for queue the methods deque, first and probably some other always check, if the queue is empty and throw an error in that case. These are a lot of unnecessary checks (unless the compiler is so clever) when you have a loop like

while !isempty(q)
    x = first(q)
    ...
    dequeue!(q)
end

Would it make sense to allow using @inbounds for such methods? I could make some PRs for that.
This might be a breaking change though, in case someone was already using these methods inside a @inbounds block and caught the error on purpose.

On the other hand, apparently Julia Dicts also do not allow one to disable boundchecks with @inbounds.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the queue entry points deque, first, isempty, and dequeue!, then compare the issue's stated behavior with how Julia Dict handles @inbounds. Done means the scope and semantics for disabling empty-check errors in queue and other data structures are decided and covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.