JuliaArrays / JuliaArrays/ArrayInterface.jl

Should we have `freeze` and `thaw`

Open
#256 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
140
Forks
44
Avg merge
4d 14h
Merged PRs (30d)
5

Description

I've seen freeze(x) and thaw(x) thrown around for making x immutable and mutable, respectively. I'm not sure if we should wait for base to formalize the ImmutableArray approach, or if it's worth have some common syntax for that right now. I'm not sure if we're ever going to get much petter than this pattern:

function foo(x)
    y = similar(x)
    foo!(y, x)
    if ismutable(x)
        return y
    else
        return freeze(y)
    end
end
# change values of `y`
foo!(y, x) = ...

Which might be fine if we can ensure that freeze(y) and similar(x) are close so that the compiler can easily figure out what to allocate to the stack and elide unnecessary allocations.

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

This is a design discussion about freeze/thaw, ImmutableArray, similar, and ismutable rather than a scoped file change. Start by reviewing Julia/Base's ImmutableArray approach and the existing array-interface conventions. Done would require agreement on whether to add common freeze/thaw syntax and a defined implementation scope, which the issue does not provide.

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
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.