# \#array

**URL:** https://discourse.julialang.org/tag/array/115.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [List comprehension can't find an already defined variable](https://discourse.julialang.org/t/list-comprehension-cant-find-an-already-defined-variable/138020)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 1\
**Last updated:** [July 9, 2026, 7:12am UTC](https://discourse.julialang.org/t/list-comprehension-cant-find-an-already-defined-variable/138020 "2026-07-09T07:12:34Z")

</div>

I was dealing with an error and in the end it seems to reduce to array comprehension: c=0 z = \[1,2,3,4\] println(\[c+=i for i in z\]) it throws an error: ERROR: LoadError: UndefVarError: c not defined in local scope Su…

---

## [Filtering Array Rows By Matching Element Value](https://discourse.julialang.org/t/filtering-array-rows-by-matching-element-value/137320)

<div class="topic-metadata">

**Author:** [@ducksoverip](https://discourse.julialang.org/u/ducksoverip)\
**Replies:** 7\
**Last updated:** [May 28, 2026, 7:05pm UTC](https://discourse.julialang.org/t/filtering-array-rows-by-matching-element-value/137320 "2026-05-28T19:05:25Z")

</div>

I’m a Julia newbie working with some inherited Fortran 90 code for research purposes. One of the things the Fortran code does is write a list of parameters to file for future use, eg: 0 0 0 1 1 0 1 1 2 0 Say the column…

---

## [Equivalent of numpy.tobytes and numpy.frombuffer in Julia](https://discourse.julialang.org/t/equivalent-of-numpy-tobytes-and-numpy-frombuffer-in-julia/136554)

<div class="topic-metadata">

**Author:** [@lilachint](https://discourse.julialang.org/u/lilachint)\
**Replies:** 4\
**Last updated:** [April 4, 2026, 4:05pm UTC](https://discourse.julialang.org/t/equivalent-of-numpy-tobytes-and-numpy-frombuffer-in-julia/136554 "2026-04-04T16:05:48Z")

</div>

Hi! As the topic stated, I once built a Python package that uses numpy.tobytes (source) and numpy.frombuffer (source) when caching things with SQLite. In Julia, I want to do this with BitArrays instead to save even more…

---

## [Is there any advantage of directly using \`Memory{T}\` over a traditional Array?](https://discourse.julialang.org/t/is-there-any-advantage-of-directly-using-memory-t-over-a-traditional-array/136062)

<div class="topic-metadata">

**Author:** [@pmc4](https://discourse.julialang.org/u/pmc4)\
**Replies:** 13\
**Last updated:** [March 7, 2026, 8:46am UTC](https://discourse.julialang.org/t/is-there-any-advantage-of-directly-using-memory-t-over-a-traditional-array/136062 "2026-03-07T08:46:23Z")

</div>

Hi, everyone. Correct me if I’m wrong, please: I understand that an Array is implemented via a MemoryRef which contains a Memory object, with supertype DenseArray. When an array is created, some memory is allocated. Me…

---

## [Combining reshape and view sometimes allocates](https://discourse.julialang.org/t/combining-reshape-and-view-sometimes-allocates/135725)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 2\
**Last updated:** [February 20, 2026, 2:31am UTC](https://discourse.julialang.org/t/combining-reshape-and-view-sometimes-allocates/135725 "2026-02-20T02:31:05Z")

</div>

I have some complicated code that uses a combination of reshape() and view(), and in my complicated code both reshape() and view() allocates. Trying to reduce my code to an MRE, I came up with this: function profile\_all…

---

## [How To Create a 2D Array of Arrays?](https://discourse.julialang.org/t/how-to-create-a-2d-array-of-arrays/135178)

<div class="topic-metadata">

**Author:** [@Grass](https://discourse.julialang.org/u/Grass)\
**Replies:** 5\
**Last updated:** [January 21, 2026, 9:50am UTC](https://discourse.julialang.org/t/how-to-create-a-2d-array-of-arrays/135178 "2026-01-21T09:50:52Z")

</div>

Is it possible to create a 2D array of (2D) arrays in Julia? If so, how can I do it? I scoured the internet but I did not manage to find out whether this is possible or not. I only managed to find information on creatin…

---

## [Array comprehension is inconsistent, given the column-major property of julia](https://discourse.julialang.org/t/array-comprehension-is-inconsistent-given-the-column-major-property-of-julia/134946)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 28\
**Last updated:** [January 18, 2026, 9:16am UTC](https://discourse.julialang.org/t/array-comprehension-is-inconsistent-given-the-column-major-property-of-julia/134946 "2026-01-18T09:16:34Z")

</div>

Related doc: Performance Tips · The Julia Language For a matrix julia\> x = \[1 2; 3 4\] 2×2 Matrix{Int64}: 1 2 3 4 The correct order of element is julia\> for e = x println(e) end 1 3 2 4 To exact…

---

## [Is it safe to broadcast \`setindex!\` with views of the same array?](https://discourse.julialang.org/t/is-it-safe-to-broadcast-setindex-with-views-of-the-same-array/133620)

<div class="topic-metadata">

**Author:** [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Replies:** 4\
**Last updated:** [November 3, 2025, 4:53pm UTC](https://discourse.julialang.org/t/is-it-safe-to-broadcast-setindex-with-views-of-the-same-array/133620 "2025-11-03T16:53:25Z")

</div>

I tried to find out looking here and through the documentation, but I couldn’t find a concrete answer so far: Is it safe to re-order array elements in-place using a view into the same array, like so: julia\> A = rand(10…

---

## [Tmap usage with views](https://discourse.julialang.org/t/tmap-usage-with-views/133556)

<div class="topic-metadata">

**Author:** [@jacobga](https://discourse.julialang.org/u/jacobga)\
**Replies:** 2\
**Last updated:** [October 31, 2025, 8:04am UTC](https://discourse.julialang.org/t/tmap-usage-with-views/133556 "2025-10-31T08:04:57Z")

</div>

Hello, I am trying to use tmap! from OhMyThreads.jl on a view of an array. When running the code normally, it works fine, but it fails in testing when run with check\_bounds=yes, because views have cartesian index style.…

---

## [C Contiguous Array in PyCall](https://discourse.julialang.org/t/c-contiguous-array-in-pycall/133559)

<div class="topic-metadata">

**Author:** [@Frauke](https://discourse.julialang.org/u/Frauke)\
**Replies:** 2\
**Last updated:** [October 30, 2025, 6:19pm UTC](https://discourse.julialang.org/t/c-contiguous-array-in-pycall/133559 "2025-10-30T18:19:45Z")

</div>

Hey everyone, I am trying to communicate with a National Instrument DAQ via PyCall.jl and the NI Python library nidaqmx. For some functions I have to pass a C contiguous array (flag C\_CONTIGUOUS has to be true). I trie…

---

## [\[ANN\]: ZeroDimensionalArrays.jl: zero-dimensional arrays/references/boxes](https://discourse.julialang.org/t/ann-zerodimensionalarrays-jl-zero-dimensional-arrays-references-boxes/128002)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 24\
**Last updated:** [October 15, 2025, 3:33pm UTC](https://discourse.julialang.org/t/ann-zerodimensionalarrays-jl-zero-dimensional-arrays-references-boxes/128002 "2025-10-15T15:33:59Z")

</div>

ZeroDimensionalArrays.jl is being registered, meaning it has entered the three-day-long wait period. Feel free to suggest breaking changes until the wait period is over! It’s a tiny package, implementing several similar…

---

## [Is there a package for block-sparse matrix processing?](https://discourse.julialang.org/t/is-there-a-package-for-block-sparse-matrix-processing/133067)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 5\
**Last updated:** [October 12, 2025, 7:46pm UTC](https://discourse.julialang.org/t/is-there-a-package-for-block-sparse-matrix-processing/133067 "2025-10-12T19:46:11Z")

</div>

As in the title, I mean every block is dense, but there are only a small percentage of non-vanishing blocks.

---

## [Sparse arrays of higher order](https://discourse.julialang.org/t/sparse-arrays-of-higher-order/42875)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 4\
**Last updated:** [September 17, 2025, 2:12am UTC](https://discourse.julialang.org/t/sparse-arrays-of-higher-order/42875 "2025-09-17T02:12:46Z")

</div>

Are there any good packages which have a similar feature as SparseArrays.SparseMatrixCSC but with higher order arrays? For example, a sparse array with 3 indices or 4 indices, stored in a similar way to a sparse matrix, …

---

## [Undefs.jl: Convenience and Experiment](https://discourse.julialang.org/t/undefs-jl-convenience-and-experiment/93451)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 12\
**Last updated:** [September 6, 2025, 12:25pm UTC](https://discourse.julialang.org/t/undefs-jl-convenience-and-experiment/93451 "2025-09-06T12:25:55Z")

</div>

Undefs.jl I created a registered package called Undefs.jl that exports three names: undefs(A = Array, T = Float64, dims) = A{T}(undef, dims): a convenience method similar to ones, zeros, trues, and falses. undef!(array…

---

## [Juliacall / PythonCall array conversion crash (now with MWE)](https://discourse.julialang.org/t/juliacall-pythoncall-array-conversion-crash-now-with-mwe/131318)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 5\
**Last updated:** [August 4, 2025, 4:38pm UTC](https://discourse.julialang.org/t/juliacall-pythoncall-array-conversion-crash-now-with-mwe/131318 "2025-08-04T16:38:04Z")

</div>

Here’s the Python code which extracts a tuple of two Julia arrays from the juliacall interface and converts them to numpy arrays. The code is an infinite loop, but crashes sporadically after a few million iterations with…

---

## [Juliacall / PythonCall array conversion error](https://discourse.julialang.org/t/juliacall-pythoncall-array-conversion-error/131311)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 0\
**Last updated:** [August 3, 2025, 3:06am UTC](https://discourse.julialang.org/t/juliacall-pythoncall-array-conversion-error/131311 "2025-08-03T03:06:57Z")

</div>

I’m using the Python package juliacall to call my Julia code. I encounter sporadic errors from lines that look like this: import numpy as np from juliacall import Main as jl jl.seval("import mypackage") jl\_mypackage = j…

---

## [Zero-overhead numpy array with juliacall](https://discourse.julialang.org/t/zero-overhead-numpy-array-with-juliacall/130335)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 7\
**Last updated:** [June 30, 2025, 8:51pm UTC](https://discourse.julialang.org/t/zero-overhead-numpy-array-with-juliacall/130335 "2025-06-30T20:51:32Z")

</div>

I want to expose a Julia package to Python users via juliacall. The function in the Julia code returns a 2D array. How can this be converted to a 2D numpy array with minimal overhead, e.g. without the cost of converting …

---

## [Literal expression for array of vectors](https://discourse.julialang.org/t/literal-expression-for-array-of-vectors/130184)

<div class="topic-metadata">

**Author:** [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Replies:** 12\
**Last updated:** [June 25, 2025, 1:06pm UTC](https://discourse.julialang.org/t/literal-expression-for-array-of-vectors/130184 "2025-06-25T13:06:12Z")

</div>

Is there an array literal that gives me this object (and a variation with some integer elements in some of the vectors)? julia\> ... 3×5 Matrix{Vector{Int64}}: \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] …

---

## [FixedSizeVectors with cache-aligned memory?](https://discourse.julialang.org/t/fixedsizevectors-with-cache-aligned-memory/129884)

<div class="topic-metadata">

**Author:** [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Replies:** 18\
**Last updated:** [June 19, 2025, 7:33pm UTC](https://discourse.julialang.org/t/fixedsizevectors-with-cache-aligned-memory/129884 "2025-06-19T19:33:33Z")

</div>

FixedSizeVectors offer a first, more performant and cleaner approach to working with (generally, numeric) vectors where, once formed, the size of the vector does not change. AlignedAllocs provides cache-aligned memory a…

---

## [How to better initialize a dictionary containing multidimensional array?](https://discourse.julialang.org/t/how-to-better-initialize-a-dictionary-containing-multidimensional-array/129632)

<div class="topic-metadata">

**Author:** [@Harrykjg-physics](https://discourse.julialang.org/u/Harrykjg-physics)\
**Replies:** 10\
**Last updated:** [June 4, 2025, 11:52am UTC](https://discourse.julialang.org/t/how-to-better-initialize-a-dictionary-containing-multidimensional-array/129632 "2025-06-04T11:52:38Z")

</div>

Hi everyone, I want to create a Dict() object where the keys are NTuple{6, Int} and the corresponding values are rank-6 arrays. I found the following function to create such Dict object with 64 items are much slower than…

---

## [Memory Comprehensions](https://discourse.julialang.org/t/memory-comprehensions/129033)

<div class="topic-metadata">

**Author:** [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Replies:** 7\
**Last updated:** [May 25, 2025, 10:51am UTC](https://discourse.julialang.org/t/memory-comprehensions/129033 "2025-05-25T10:51:04Z")

</div>

Is there a Memory comprehension in Julia, which I missed so far? We have Array comprehensions, but when you don’t need the multiple dimensions and resizing properties of an Array and a Memory is enough, it would be nice…

---

## [How to build a wrapper around a C-style array using Julia C API?](https://discourse.julialang.org/t/how-to-build-a-wrapper-around-a-c-style-array-using-julia-c-api/129469)

<div class="topic-metadata">

**Author:** [@dmitry-kabanov](https://discourse.julialang.org/u/dmitry-kabanov)\
**Replies:** 4\
**Last updated:** [May 31, 2025, 12:55am UTC](https://discourse.julialang.org/t/how-to-build-a-wrapper-around-a-c-style-array-using-julia-c-api/129469 "2025-05-31T00:55:11Z")

</div>

Hi, I need to use the Julia C API to build a wrapper around a C-style array to use this array in Julia (the array is actually a Python NumPy array). The thing is that the array is a matrix (2D) and Julia uses Fortran-sty…

---

## [Something weird is going on with \`DenseArray\`](https://discourse.julialang.org/t/something-weird-is-going-on-with-densearray/129156)

<div class="topic-metadata">

**Author:** [@akriegman](https://discourse.julialang.org/u/akriegman)\
**Replies:** 3\
**Last updated:** [May 19, 2025, 11:24pm UTC](https://discourse.julialang.org/t/something-weird-is-going-on-with-densearray/129156 "2025-05-19T23:24:22Z")

</div>

From base/boot.jl: # commented-out definitions are implemented in C ... #abstract type AbstractArray{T,N} end #abstract type DenseArray{T,N} \<: AbstractArray{T,N} end ... #mutable struct Array{T,N} \<: DenseArray{T,N…

---

## [Checking strided array storage order](https://discourse.julialang.org/t/checking-strided-array-storage-order/128685)

<div class="topic-metadata">

**Author:** [@stemann](https://discourse.julialang.org/u/stemann)\
**Replies:** 1\
**Last updated:** [May 4, 2025, 11:18am UTC](https://discourse.julialang.org/t/checking-strided-array-storage-order/128685 "2025-05-04T11:18:08Z")

</div>

Is strides(array) == Base.size\_to\_strides(1, size(array)...) a sane way to check if a strided array is in column-major (alias co-lexicographic, alias Fortran, alias Julia) order, storage-wise? Cf. julia/base/abstracta…

---

## [Dynamic immutable type](https://discourse.julialang.org/t/dynamic-immutable-type/127168)

<div class="topic-metadata">

**Author:** [@Soel](https://discourse.julialang.org/u/Soel)\
**Replies:** 11\
**Last updated:** [April 12, 2025, 10:19am UTC](https://discourse.julialang.org/t/dynamic-immutable-type/127168 "2025-04-12T10:19:33Z")

</div>

Hello Julians, I’m trying to design a type MyType having a certain number of fields amongst which matrix::AbstractMatrix. In production MyType is intended to have its field matrix modified (hundreds times a day)… I’ve e…

---

## [Getting MutableNamedTuple keys from an empty array](https://discourse.julialang.org/t/getting-mutablenamedtuple-keys-from-an-empty-array/127387)

<div class="topic-metadata">

**Author:** [@s\_amap](https://discourse.julialang.org/u/s_amap)\
**Replies:** 18\
**Last updated:** [April 3, 2025, 8:58am UTC](https://discourse.julialang.org/t/getting-mutablenamedtuple-keys-from-an-empty-array/127387 "2025-04-03T08:58:29Z")

</div>

Hmm, I have an empty Vector of MutableNamedTuples with a specific signature, ie if the array has a single element, then I can recover the keys of the underlying NamedTuple by inspecting the element. But what if the arr…

---

## [Memory \`isbits\` Union Optimization](https://discourse.julialang.org/t/memory-isbits-union-optimization/126175)

<div class="topic-metadata">

**Author:** [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Replies:** 5\
**Last updated:** [February 23, 2025, 8:23am UTC](https://discourse.julialang.org/t/memory-isbits-union-optimization/126175 "2025-02-23T08:23:03Z")

</div>

Citing from isbits union memory optimization (emphasis mine) The optimization is accomplished by storing an extra “type tag memory” of bytes, one byte per element, alongside the bytes of the actual data. However, I s…

---

## [Understanding \`Base.findall\` and customizing it](https://discourse.julialang.org/t/understanding-base-findall-and-customizing-it/125220)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 2\
**Last updated:** [January 26, 2025, 1:24pm UTC](https://discourse.julialang.org/t/understanding-base-findall-and-customizing-it/125220 "2025-01-26T13:24:58Z")

</div>

Given a vector ww, I wish to obtain all its nonzero values and the corresponding positions (with specified type). I solve this with: using BenchmarkTools, Test function \_find0(::tp, ww::AbstractVector{tw}) ::Tuple{Vecto…

---

## [Virtual (or lazy) representation of a repeated array](https://discourse.julialang.org/t/virtual-or-lazy-representation-of-a-repeated-array/124954)

<div class="topic-metadata">

**Author:** [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)\
**Replies:** 4\
**Last updated:** [January 22, 2025, 12:22pm UTC](https://discourse.julialang.org/t/virtual-or-lazy-representation-of-a-repeated-array/124954 "2025-01-22T12:22:50Z")

</div>

Is there an array type, that allows me to create a virtual (or lazy) representation of the following array x ? sz = (64, 64, 2, 10589) tmp = reshape(range(-1,1,64),(:,1,1,1)); x = repeat(tmp,1,sz\[2\],sz\[3\],sz\[4\]); It …

---

## [Help with reducing allocations when indexing into custom Array](https://discourse.julialang.org/t/help-with-reducing-allocations-when-indexing-into-custom-array/124732)

<div class="topic-metadata">

**Author:** [@thomasc791](https://discourse.julialang.org/u/thomasc791)\
**Replies:** 10\
**Last updated:** [January 14, 2025, 10:21pm UTC](https://discourse.julialang.org/t/help-with-reducing-allocations-when-indexing-into-custom-array/124732 "2025-01-14T22:21:09Z")

</div>

Hi everyone, I am quite new to the language, and was wondering if people could help me optimising my piece of code. The idea for this array type is to reduce the total Base.summarysize for a vector of vector as much as …

[Next page](https://discourse.julialang.org/tag/array/115.md?match_all_tags=true&page=1&tags%5B%5D=array)
