Skip to content

[Feature]: Include static arrays #266

@CWillberg

Description

@CWillberg

What are you trying to do and how would you want to do it differently?

I would like to store the nlist, inverse_nlist, nodes and block_nodes in staticvectors. These vectors cannot be stored in Dicts.

Is it something you currently cannot do? Is this related to an issue/problem?

The memory allocation is drastically reduced.

Implementation details

using BenchmarkTools
using StaticArrays
data=Dict()
nnodes=10
const nodes = 1:nnodes
const nBonds = fill(nnodes, nnodes)
const nlist = [@svector fill(0, n) for n in nBonds]

const mydata = (a = SVector{nnodes}(nodes), b =nlist)

data["nodes"]=SVector{nnodes}(nodes)
data["nlist"]=nlist

function named_tuple()
for iID in mydata.a
for jID in eachindex(mydata.b[iID])

    end
end

end

@Btime named_tuple()

  • It do not has to be a named tuple.
  • dicts are not possible
  • seperate variables are possible
  • nlist ist than not callable via the get_field option, only via get_nlist()

Would you be willing to submit a PR?

No

Metadata

Metadata

Labels

featureNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions