# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=24

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

**Page:** 25

---

## [Static vectors of vectors slow?](https://discourse.julialang.org/t/static-vectors-of-vectors-slow/134720)

<div class="topic-metadata">

**Author:** [@rokke](https://discourse.julialang.org/u/rokke)\
**Replies:** 3\
**Last updated:** [December 24, 2025, 12:11pm UTC](https://discourse.julialang.org/t/static-vectors-of-vectors-slow/134720 "2025-12-24T12:11:17Z")

</div>

first, I introduce some very similar ways to represent some boring data, with reasonable benchmarks: julia\> a=SVector{3, MVector{3,Int}}(\[MVector{3,Int}(\[1,1,1\]),MVector{3,Int}(\[1,1,1\]),MVector{3,Int}(\[1,1,1\])\]) 3-eleme…

---

## [OncePerTask case](https://discourse.julialang.org/t/oncepertask-case/134719)

<div class="topic-metadata">

**Author:** [@yolhan\_mannes](https://discourse.julialang.org/u/yolhan_mannes)\
**Replies:** 1\
**Last updated:** [December 24, 2025, 11:10am UTC](https://discourse.julialang.org/t/oncepertask-case/134719 "2025-12-24T11:10:54Z")

</div>

Hello, sorry I keep forgetting how to do this : function main() n = UInt128(10^7) input ::Vector{UInt128} = collect(0:n-1) result = OncePerTask() do Ref(UInt128(0)) end Threads.@threads for i in in…

---

## [Is it posible to serialize a Makie.Figure object?](https://discourse.julialang.org/t/is-it-posible-to-serialize-a-makie-figure-object/134686)

<div class="topic-metadata">

**Author:** [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Replies:** 2\
**Last updated:** [December 24, 2025, 4:33am UTC](https://discourse.julialang.org/t/is-it-posible-to-serialize-a-makie-figure-object/134686 "2025-12-24T04:33:04Z")

</div>

I’ve tried with JLD2 and Serialization. InJLD2, the warnings were, it can’t save anonymous functions, while Serialization errored with “cannot serialize a running Task”. So probably no chance? This is the context.

---

## [Developing MPI code using VSCode](https://discourse.julialang.org/t/developing-mpi-code-using-vscode/130108)

<div class="topic-metadata">

**Author:** [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Replies:** 5\
**Last updated:** [December 24, 2025, 1:13am UTC](https://discourse.julialang.org/t/developing-mpi-code-using-vscode/130108 "2025-12-24T01:13:02Z")

</div>

Hi everyone, I want to parallelize some code on multiple nodes and am considering MPI.jl One thing that feels a bit suboptimal, is that MPI seems quite incompatible with the interactive workflow. Ideally, I would like …

---

## [Understanding iterate() documentation is tough](https://discourse.julialang.org/t/understanding-iterate-documentation-is-tough/134715)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 3\
**Last updated:** [December 24, 2025, 12:32am UTC](https://discourse.julialang.org/t/understanding-iterate-documentation-is-tough/134715 "2025-12-24T00:32:35Z")

</div>

Understanding iterate() documentation is made tough although everyone use it easily. Is Julia for loop behind the scene a while loop? julia\> for i in 1:5 println(i) end is equivalent to :down\_arrow: …

---

## [Confusion about periodic BCs in NearestNeighbors.jl](https://discourse.julialang.org/t/confusion-about-periodic-bcs-in-nearestneighbors-jl/134706)

<div class="topic-metadata">

**Author:** [@Barabule](https://discourse.julialang.org/u/Barabule)\
**Replies:** 2\
**Last updated:** [December 23, 2025, 5:00pm UTC](https://discourse.julialang.org/t/confusion-about-periodic-bcs-in-nearestneighbors-jl/134706 "2025-12-23T17:00:17Z")

</div>

Hi, I’m trying to make a periodic tree in NearestNeigbors with a custom Distance metric struct SegmentDistance \<:Metric; end function parameters(::SegmentDistance) nothing end The idea is to compute line segment …

---

## [How to efficiently update a Sparse Matrix (Diagonal + Sparse) in-place inside a hot loop?](https://discourse.julialang.org/t/how-to-efficiently-update-a-sparse-matrix-diagonal-sparse-in-place-inside-a-hot-loop/134705)

<div class="topic-metadata">

**Author:** [@Matt\_jl](https://discourse.julialang.org/u/Matt_jl)\
**Replies:** 3\
**Last updated:** [December 23, 2025, 3:51pm UTC](https://discourse.julialang.org/t/how-to-efficiently-update-a-sparse-matrix-diagonal-sparse-in-place-inside-a-hot-loop/134705 "2025-12-23T15:51:57Z")

</div>

Hi everyone, I am working on an iterative algorithm where I need to construct and solve a linear system inside a “hot loop”. Currently, my code allocates a new sparse matrix A at every iteration because of the operati…

---

## [Julia -p N --project=... does not work](https://discourse.julialang.org/t/julia-p-n-project-does-not-work/134682)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [December 23, 2025, 8:09am UTC](https://discourse.julialang.org/t/julia-p-n-project-does-not-work/134682 "2025-12-23T08:09:40Z")

</div>

I was expecting the --project switch to apply to all processes, but apparently it does not. Is this a bug, or something by design? (I can work around this with @everywhere Pkg.activate(...), that is not the issue. I enc…

---

## [JETLS warnings](https://discourse.julialang.org/t/jetls-warnings/134700)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 2\
**Last updated:** [December 23, 2025, 5:55am UTC](https://discourse.julialang.org/t/jetls-warnings/134700 "2025-12-23T05:55:35Z")

</div>

I have the following code: local pos\_B, pos\_C, pos\_D for i in 1:4 particle=particles\[i\] x, y, z = particle\[1\], particle\[2\], particle\[3\] if i==2 pos\_B = SVector(x,y,z) …

---

## [Bayesian Optimization with Julia](https://discourse.julialang.org/t/bayesian-optimization-with-julia/75143)

<div class="topic-metadata">

**Author:** [@xspeng](https://discourse.julialang.org/u/xspeng)\
**Replies:** 6\
**Last updated:** [December 22, 2025, 9:08pm UTC](https://discourse.julialang.org/t/bayesian-optimization-with-julia/75143 "2025-12-22T21:08:34Z")

</div>

Hi, anyone knows how to use bayesian optimization to get the minimum value of a blackbox function, I read the manual of BayesianOptimization.jl https://github.com/jbrea/BayesianOptimization.jl but it’s not easy to unde…

---

## [Agents.jl periodic=true still gives space extent errors](https://discourse.julialang.org/t/agents-jl-periodic-true-still-gives-space-extent-errors/134605)

<div class="topic-metadata">

**Author:** [@BananaMaster3](https://discourse.julialang.org/u/BananaMaster3)\
**Replies:** 5\
**Last updated:** [December 21, 2025, 1:38am UTC](https://discourse.julialang.org/t/agents-jl-periodic-true-still-gives-space-extent-errors/134605 "2025-12-21T01:38:15Z")

</div>

Hey all, I have a continuous, periodic space ABM. My ABM declaration looks like this: space2d = ContinuousSpace(extent; periodic=true, ); model = Agent…

---

## [Truncation error in ITensors SVD](https://discourse.julialang.org/t/truncation-error-in-itensors-svd/134559)

<div class="topic-metadata">

**Author:** [@diffeqslvr](https://discourse.julialang.org/u/diffeqslvr)\
**Replies:** 2\
**Last updated:** [December 19, 2025, 10:14pm UTC](https://discourse.julialang.org/t/truncation-error-in-itensors-svd/134559 "2025-12-19T22:14:05Z")

</div>

I am trying to understand the truncation error when performing an SVD using ITensors. According to ITensor Examples · ITensors.jl, the truncation error is defined as sum\_{discarded n} lambda\_n^2 / sum\_{n} lambda\_n^2, whe…

---

## [Int -\> Str -\> print(io,\_) without allocations](https://discourse.julialang.org/t/int-str-print-io-without-allocations/134626)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 16\
**Last updated:** [December 19, 2025, 11:53am UTC](https://discourse.julialang.org/t/int-str-print-io-without-allocations/134626 "2025-12-19T11:53:12Z")

</div>

I have billions of Ints that I wish to write to a file. Something similar to mmwrite() in MatrixMarket.jl. I am already using IOBuffer with a large enough sizehint. When I do print(io, n::Int), behind the scenes, a conve…

---

## [Current state of reaction-diffusion solvers with ModelingToolkit](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492)

<div class="topic-metadata">

**Author:** [@Alicanter](https://discourse.julialang.org/u/Alicanter)\
**Replies:** 10\
**Last updated:** [December 18, 2025, 9:49pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492 "2025-12-18T21:49:48Z")

</div>

I am trying to solve a reaction-diffusion in Julia. I’ve worked with ModelingToolkit and the SciML ecosystem before, but it seems that with PDEs there is not a single best way to solve them. The simplest way I found to…

---

## [What is the correct way to use Base.OncePerThread?](https://discourse.julialang.org/t/what-is-the-correct-way-to-use-base-onceperthread/134597)

<div class="topic-metadata">

**Author:** [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Replies:** 7\
**Last updated:** [December 18, 2025, 4:52pm UTC](https://discourse.julialang.org/t/what-is-the-correct-way-to-use-base-onceperthread/134597 "2025-12-18T16:52:42Z")

</div>

I want to use Base.OncePerThread but it’s not clear what the intended usage is. Is the following a correct / safe / intended way to use Base.OncePerThread ? finalset = Set() tempsets = OncePerThread() do return Set…

---

## [Understanding allocations reported by --track-allocation (solved)](https://discourse.julialang.org/t/understanding-allocations-reported-by-track-allocation-solved/134628)

<div class="topic-metadata">

**Author:** [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Replies:** 1\
**Last updated:** [December 18, 2025, 11:48am UTC](https://discourse.julialang.org/t/understanding-allocations-reported-by-track-allocation-solved/134628 "2025-12-18T11:48:21Z")

</div>

I’m trying to understand the output of --track-allocation=user on this very straightforward snippet: mutable struct S n positions end function S(n) return S(n, zeros(Float32,n)) end function (@main)(args) …

---

## [Convert or Reinterpret Between NamedTuple and SVector](https://discourse.julialang.org/t/convert-or-reinterpret-between-namedtuple-and-svector/134600)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 7\
**Last updated:** [December 17, 2025, 7:33pm UTC](https://discourse.julialang.org/t/convert-or-reinterpret-between-namedtuple-and-svector/134600 "2025-12-17T19:33:07Z")

</div>

My question is related to Vector to NamedTuple? Assume my NamedTuple contains only floating point values T and SVector{N, T} entries, e.g., using StaticArrays nt = ( a = rand(), b = SA\[1.0, 2.0 ,3.0\] ) Taking such a N…

---

## [Switching off implicit conversion](https://discourse.julialang.org/t/switching-off-implicit-conversion/134568)

<div class="topic-metadata">

**Author:** [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Replies:** 25\
**Last updated:** [December 17, 2025, 2:04pm UTC](https://discourse.julialang.org/t/switching-off-implicit-conversion/134568 "2025-12-17T14:04:29Z")

</div>

Let’s work with an example. Say I have two different units of length. abstract type Length end struct Meters \<: Length value::Float64 end struct CentiMeters \<: Length value::Float64 end I want to use the existing…

---

## [Distributed workflow for MCMC](https://discourse.julialang.org/t/distributed-workflow-for-mcmc/134590)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [December 17, 2025, 1:43pm UTC](https://discourse.julialang.org/t/distributed-workflow-for-mcmc/134590 "2025-12-17T13:43:26Z")

</div>

I would like to set up an MCMC workflow using Distributed. I have a Julia script that does the following: load all packages load the data run an MCMC chain, with index i, for i in 1:5 save the result in some\_chain\_$i.…

---

## [Please Guide Newcomers How To Write Typestable Code](https://discourse.julialang.org/t/please-guide-newcomers-how-to-write-typestable-code/134606)

<div class="topic-metadata">

**Author:** [@ziolai](https://discourse.julialang.org/u/ziolai)\
**Replies:** 1\
**Last updated:** [December 17, 2025, 7:52am UTC](https://discourse.julialang.org/t/please-guide-newcomers-how-to-write-typestable-code/134606 "2025-12-17T07:52:57Z")

</div>

Various students of mine struggle in understanding the issue of type stability and memory allocations. What reading material and tutorials should I give them? Thx!

---

## [Trouble with installing AlphaShapes package](https://discourse.julialang.org/t/trouble-with-installing-alphashapes-package/134599)

<div class="topic-metadata">

**Author:** [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)\
**Replies:** 6\
**Last updated:** [December 17, 2025, 3:01am UTC](https://discourse.julialang.org/t/trouble-with-installing-alphashapes-package/134599 "2025-12-17T03:01:28Z")

</div>

I am very interested in using the AlphaShapes.jl package. However after installation, I get the following error when I try to load it for the first time. I would appreciate any help with troubleshoorting. julia\> using …

---

## [Julia 1.11.8 performance up a notch since 1.11.7 (was: down a notch)](https://discourse.julialang.org/t/julia-1-11-8-performance-up-a-notch-since-1-11-7-was-down-a-notch/134577)

<div class="topic-metadata">

**Author:** [@JJMerelo](https://discourse.julialang.org/u/JJMerelo)\
**Replies:** 4\
**Last updated:** [December 16, 2025, 11:59pm UTC](https://discourse.julialang.org/t/julia-1-11-8-performance-up-a-notch-since-1-11-7-was-down-a-notch/134577 "2025-12-16T23:59:56Z")

</div>

As you may know, I’m using Julia for performance/energy evaluation here GitHub - cecimerelo/BraveNewAlgorithm.jl I routinely test new versions for improvements… After initially measuring a downgraded performance, I took…

---

## [Issues with JuliaFormatter and JET tests on 1.12](https://discourse.julialang.org/t/issues-with-juliaformatter-and-jet-tests-on-1-12/134596)

<div class="topic-metadata">

**Author:** [@rsenne](https://discourse.julialang.org/u/rsenne)\
**Replies:** 3\
**Last updated:** [December 16, 2025, 10:43pm UTC](https://discourse.julialang.org/t/issues-with-juliaformatter-and-jet-tests-on-1-12/134596 "2025-12-16T22:43:23Z")

</div>

I have tests like this across a few packages: @testset verbose=true "Package Quality" begin @testset "Blue Formatting" begin @test\_broken JuliaFormatter.format(MyPackage; verbose=false, overwr…

---

## [Error loading OpenSSL\_jll (“version OPENSSL\_3.3.0 not found”) when precompiling MLDatasets](https://discourse.julialang.org/t/error-loading-openssl-jll-version-openssl-3-3-0-not-found-when-precompiling-mldatasets/128977)

<div class="topic-metadata">

**Author:** [@josemanuel22](https://discourse.julialang.org/u/josemanuel22)\
**Replies:** 8\
**Last updated:** [December 16, 2025, 2:43pm UTC](https://discourse.julialang.org/t/error-loading-openssl-jll-version-openssl-3-3-0-not-found-when-precompiling-mldatasets/128977 "2025-12-16T14:43:10Z")

</div>

Environment Julia version: 1.8 OS: Linux (64-bit) OpenSSL\_jll artifact path: /export/usuarios01/jmfrutos/.julia/artifacts/a696e1e3e6b8d3c2c4b67609357ebc5c35eabde1/lib/libssl.so When I run: using MLDatasets I get th…

---

## [Julia 1.12.3 stopped outputting top-level println strings](https://discourse.julialang.org/t/julia-1-12-3-stopped-outputting-top-level-println-strings/134583)

<div class="topic-metadata">

**Author:** [@phma](https://discourse.julialang.org/u/phma)\
**Replies:** 4\
**Last updated:** [December 16, 2025, 11:10am UTC](https://discourse.julialang.org/t/julia-1-12-3-stopped-outputting-top-level-println-strings/134583 "2025-12-16T11:10:37Z")

</div>

I have a repo on two computers, one of which I just upgraded to Julia 1.12.3. There are some println statements not in any function. I start Julia on both computers and load the project with using. This is output: phma@…

---

## [Can a callback be triggered at the initial time point (at t=0)](https://discourse.julialang.org/t/can-a-callback-be-triggered-at-the-initial-time-point-at-t-0/114376)

<div class="topic-metadata">

**Author:** [@valerdam](https://discourse.julialang.org/u/valerdam)\
**Replies:** 3\
**Last updated:** [December 16, 2025, 10:54am UTC](https://discourse.julialang.org/t/can-a-callback-be-triggered-at-the-initial-time-point-at-t-0/114376 "2025-12-16T10:54:09Z")

</div>

I am using the code from advanced\_simulations - (the one using CallbackSets) and just modified the time to include t=0.0. ps\_cb\_1 = PresetTimeCallback(\[3.0, 7.0\], integ -\> integ\[:X1\] += 5.0) and added a time zero ps\_c…

---

## [Sharing a reference across multiple threads](https://discourse.julialang.org/t/sharing-a-reference-across-multiple-threads/134538)

<div class="topic-metadata">

**Author:** [@freeman](https://discourse.julialang.org/u/freeman)\
**Replies:** 14\
**Last updated:** [December 16, 2025, 9:12am UTC](https://discourse.julialang.org/t/sharing-a-reference-across-multiple-threads/134538 "2025-12-16T09:12:01Z")

</div>

Suppose I have a reference that’s shared across two threads. One of the threads only sets the reference, and the other only dereferences it. Does this need a lock around the reference? On setting, on dereferencing, or b…

---

## [How to organize modules in a composable way?](https://discourse.julialang.org/t/how-to-organize-modules-in-a-composable-way/134536)

<div class="topic-metadata">

**Author:** [@mj2984](https://discourse.julialang.org/u/mj2984)\
**Replies:** 6\
**Last updated:** [December 16, 2025, 7:46am UTC](https://discourse.julialang.org/t/how-to-organize-modules-in-a-composable-way/134536 "2025-12-16T07:46:04Z")

</div>

Suppose I have a module module\_init that defines a type init\_struct, and I am now trying to make multiple modules in different projects that build on top of this init\_struct. For example ./project\_init/src/module\_init.j…

---

## [2-based indexing](https://discourse.julialang.org/t/2-based-indexing/134275)

<div class="topic-metadata">

**Author:** [@healyp](https://discourse.julialang.org/u/healyp)\
**Replies:** 14\
**Last updated:** [December 16, 2025, 12:01am UTC](https://discourse.julialang.org/t/2-based-indexing/134275 "2025-12-16T00:01:23Z")

</div>

The 1.13 alpha release announcement talks about 2-based indexing. I can find no useful discussion of what this means. Can anybody please explain the value / significance of 2-based indexing of arrays?

---

## [Very slow training of Neural ODE with exogeneous input compared to jax using dense interpolated solution](https://discourse.julialang.org/t/very-slow-training-of-neural-ode-with-exogeneous-input-compared-to-jax-using-dense-interpolated-solution/134557)

<div class="topic-metadata">

**Author:** [@johtok](https://discourse.julialang.org/u/johtok)\
**Replies:** 4\
**Last updated:** [December 15, 2025, 11:09pm UTC](https://discourse.julialang.org/t/very-slow-training-of-neural-ode-with-exogeneous-input-compared-to-jax-using-dense-interpolated-solution/134557 "2025-12-15T23:09:39Z")

</div>

Hi guys! Ive been breaking my neck trying to get a julia alternative to this jax neural ode with exogeneous input script working but without luck! The julia version is painfully slow whereas the jax version runs in a c…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=23)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=25)
