This file provides guidance to LLMs when working with code in this repository.
MemoryViews.jl provides MemoryView, a low-level view into Memory{T} for Julia ≥ 1.11. It's a DenseVector{T} subtype representing a MemoryRef{T} + length, with static mutability tracking via type parameter (Mutable/Immutable). The package also defines the MemoryKind trait for dispatch on memory-backed types.
# Run tests
JULIA_TEST_FAILFAST=true julia --startup=no --project -e 'using Pkg; Pkg.test()'
# Format code
runic -i .When running in test mode, Julia has boundscheck always enabled. When running normally,
out-of-bounds access in functions marked @inbounds is undefined behaviour.
Set --check-bounds=yes to force boundschecking when running experiments.
Core types (defined in src/MemoryViews.jl):
MemoryView{T, M}whereM ∈ {Mutable, Immutable}— the main typeMemoryKindtrait:IsMemory{T}/NotMemoryfor dispatch
Source files:
construction.jl— constructors from Array, Memory, String, SubArray, CodeUnitsbasic.jl— indexing, slicing (returns views, not copies), copying, find operations with memchr/memrchr C calls, comparison via memcmpdelimited.jl—split_eachdelimiter iteratorbase_arrays.jl— Vector/Memory conversion, appendio.jl—readbytes!
Extensions (ext/): StringViews, FixedSizeArrays, LibDeflate integration.
- Slicing creates views into the same memory (no allocation)
- Performance-critical paths use
@ccallto libc (memset,memcmp,memchr,memrchr) withGC.@preserve - Version-conditional code for Julia 1.12+ vs 1.13+ (e.g.,
Base.memoryindexforparentindices) - Trait-based dispatch pattern: define
foo(x)→foo(MemoryKind(typeof(x)), x)→ specialized onIsMemory/NotMemory @boundscheck/@inboundsused throughout for safe-by-default with opt-in elision