Skip to content

kmsherbertvt/TemporaryArrays.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TemporaryArrays

Stable Dev Build Status Coverage

This package provides the macro @temparray, which allocates an array, for temporary use in a local scope.

Subsequent calls with the same signature (e.g. from the same line of code repeated in a loop) will be allocated the same array, without any extra allocations.

using TemporaryArrays
a1 = @temparray(Float64, (3,4), :same)
a2 = @temparray(Float64, (3,4), :same)
a3 = @temparray(Float64, (3,4), :different)

@assert eltype(a1) == Float64
@assert size(a1) == (3,4)
@assert a1 === a2
@assert a1 !== a3

The point is to be able to use "work variables" that persist and get re-used throughout a computation, but in a julianic and readable way.

In order for this to be worthy of the Julia registry:

  • Figure out how to get this to work across multiple threads.

    Does Memoization.jl use the same cache for all threads? I don't know. If not, there's nothing to do. If it does, our macro should insert another symbol into the index, unique to the thread. Or, if that unavoidably incurs some allocation, I would be content to simply include an example in the README.

About

Julianic and readable approach to reusable work arrays

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages