# General Usage

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

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

**Page:** 79

---

## [Threads are not speeding up computation a lot](https://discourse.julialang.org/t/threads-are-not-speeding-up-computation-a-lot/126305)

<div class="topic-metadata">

**Author:** [@Nyan](https://discourse.julialang.org/u/Nyan)\
**Replies:** 70\
**Last updated:** [March 20, 2025, 6:00am UTC](https://discourse.julialang.org/t/threads-are-not-speeding-up-computation-a-lot/126305 "2025-03-20T06:00:03Z")

</div>

Hi. I googled and read many things about this topic, but cannot figure up what is the problem, and why I see no meaningful speedup for my code. My code: module Keygen using Base.Threads using Base.Iterators include("./…

---

## [Floops multithreading HasBoxedVariableError](https://discourse.julialang.org/t/floops-multithreading-hasboxedvariableerror/127139)

<div class="topic-metadata">

**Author:** [@s\_amap](https://discourse.julialang.org/u/s_amap)\
**Replies:** 7\
**Last updated:** [March 19, 2025, 3:54pm UTC](https://discourse.julialang.org/t/floops-multithreading-hasboxedvariableerror/127139 "2025-03-19T15:54:34Z")

</div>

I’ve been trying to adjust a parallel loop after some changes, and I need some clarification to make sure I’m not at risk of false sharing. The loop conceptually works like this: object # holds a state, which is a tupl…

---

## [Understanding GC time](https://discourse.julialang.org/t/understanding-gc-time/127127)

<div class="topic-metadata">

**Author:** [@pjuergens](https://discourse.julialang.org/u/pjuergens)\
**Replies:** 1\
**Last updated:** [March 19, 2025, 11:51am UTC](https://discourse.julialang.org/t/understanding-gc-time/127127 "2025-03-19T11:51:14Z")

</div>

Hello together, I am wondering what determines the time that the garbage collector needs. I have a complex simulation where I was hunting down allocations, but surprisingly even though I could heavily reduce number and …

---

## [A proper introduction on how to update julia somewhere accessible?](https://discourse.julialang.org/t/a-proper-introduction-on-how-to-update-julia-somewhere-accessible/28166)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 14\
**Last updated:** [March 19, 2025, 9:44am UTC](https://discourse.julialang.org/t/a-proper-introduction-on-how-to-update-julia-somewhere-accessible/28166 "2025-03-19T09:44:48Z")

</div>

So I recently had to update Julia. After some hand-holding from a colleague it worked out. I’ve had to do this two times before, the first time it worked out fine after someone at JuliaCon did it for me. The second time …

---

## [What can and cannot be in a C-callback?](https://discourse.julialang.org/t/what-can-and-cannot-be-in-a-c-callback/126840)

<div class="topic-metadata">

**Author:** [@ejmeitz](https://discourse.julialang.org/u/ejmeitz)\
**Replies:** 13\
**Last updated:** [March 18, 2025, 11:03pm UTC](https://discourse.julialang.org/t/what-can-and-cannot-be-in-a-c-callback/126840 "2025-03-18T23:03:14Z")

</div>

I’ve been messing around with registering callbacks in a C-library from Julia and ran into some things I cannot explain. The main thing I do not understand is that my code works fine from a Julia script that I either run…

---

## [How can I use pre-allocated vectors in a private way?](https://discourse.julialang.org/t/how-can-i-use-pre-allocated-vectors-in-a-private-way/127111)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 7\
**Last updated:** [March 18, 2025, 9:12pm UTC](https://discourse.julialang.org/t/how-can-i-use-pre-allocated-vectors-in-a-private-way/127111 "2025-03-18T21:12:45Z")

</div>

For performance reasons I want to use pre-allocated vectors. This often gives a 10 to 35 times perfomance boost. Simple example: using Parameters @with\_kw struct Solver{P} vec1::Vector{Float64} = zeros(P) vec2…

---

## [I can't change color or alpha parameter of wireframe surface](https://discourse.julialang.org/t/i-cant-change-color-or-alpha-parameter-of-wireframe-surface/127104)

<div class="topic-metadata">

**Author:** [@sesamelimit](https://discourse.julialang.org/u/sesamelimit)\
**Replies:** 1\
**Last updated:** [March 18, 2025, 8:40pm UTC](https://discourse.julialang.org/t/i-cant-change-color-or-alpha-parameter-of-wireframe-surface/127104 "2025-03-18T20:40:44Z")

</div>

no matter what i do it stays black, i wanted it to be more transparent, so i could plot line behind it, but it doesn’t seem to work. I’ve tried all alpha parameters, then i’ve just tried to color the line itself and i…

---

## [InexactError vs OverflowError](https://discourse.julialang.org/t/inexacterror-vs-overflowerror/127108)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 3\
**Last updated:** [March 18, 2025, 7:05pm UTC](https://discourse.julialang.org/t/inexacterror-vs-overflowerror/127108 "2025-03-18T19:05:55Z")

</div>

I have a number type which throws when the result of a binary operation like + or \* is not representable in this type. I think InexactError is the right choice of exception, while OverflowError seems like a bad choice be…

---

## [BitIntegers: creation in loop; how to avoid allocations?](https://discourse.julialang.org/t/bitintegers-creation-in-loop-how-to-avoid-allocations/115935)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 6\
**Last updated:** [March 18, 2025, 3:30pm UTC](https://discourse.julialang.org/t/bitintegers-creation-in-loop-how-to-avoid-allocations/115935 "2025-03-18T15:30:36Z")

</div>

I asked this question in a GitHub issue but got no replies: I’d like to create all BitIntegers of byte length up to 1024. I don’t want to write 128 lines of code for that, so I’m trying to use a loop. Running the follow…

---

## [Applying Dirichlet boundary conditions to assembled forcing terms](https://discourse.julialang.org/t/applying-dirichlet-boundary-conditions-to-assembled-forcing-terms/127092)

<div class="topic-metadata">

**Author:** [@Simons](https://discourse.julialang.org/u/Simons)\
**Replies:** 1\
**Last updated:** [March 18, 2025, 12:56pm UTC](https://discourse.julialang.org/t/applying-dirichlet-boundary-conditions-to-assembled-forcing-terms/127092 "2025-03-18T12:56:32Z")

</div>

Hi, I’m interested in solving a sequence of finite element problems a(u\_n,v) = b\_n(v) (A x\_n = b\_n in assembled form), all of which have the same boundary conditions. Since A is constant, I want to avoid re-assembling A…

---

## [Julia (standard) library vs. Python's (standard) library or Java's](https://discourse.julialang.org/t/julia-standard-library-vs-pythons-standard-library-or-javas/122877)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 1\
**Last updated:** [March 18, 2025, 8:58am UTC](https://discourse.julialang.org/t/julia-standard-library-vs-pythons-standard-library-or-javas/122877 "2025-03-18T08:58:33Z")

</div>

Famously Python has or had batteries included, but they have dropped a lot of modules/“dead batteries”: They actually needed to have more in their standard library, at some point, now less of a need with package manag…

---

## [Two-sided moving average with intermittent missing data:](https://discourse.julialang.org/t/two-sided-moving-average-with-intermittent-missing-data/126937)

<div class="topic-metadata">

**Author:** [@GeodeticR](https://discourse.julialang.org/u/GeodeticR)\
**Replies:** 13\
**Last updated:** [March 18, 2025, 6:55am UTC](https://discourse.julialang.org/t/two-sided-moving-average-with-intermittent-missing-data/126937 "2025-03-18T06:55:57Z")

</div>

I think I’m over-thinking this issue I’m having when trying to use a two-sided moving average. All I want to do is create a two-sided moving window that “doesn’t care” about missing data in my GPS timeseries. As long a…

---

## [Pairwise reduction significantly slower than two scalar reductions](https://discourse.julialang.org/t/pairwise-reduction-significantly-slower-than-two-scalar-reductions/127064)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 11\
**Last updated:** [March 18, 2025, 12:33am UTC](https://discourse.julialang.org/t/pairwise-reduction-significantly-slower-than-two-scalar-reductions/127064 "2025-03-18T00:33:17Z")

</div>

I’ve written two reductions which both do the same thing: compute the sum and the squared norm of a vector. One does this in one pass through the data, accumulating two values as it goes. The second does two passes throu…

---

## [Metaprogramming: prefer functions with eval or macros?](https://discourse.julialang.org/t/metaprogramming-prefer-functions-with-eval-or-macros/127066)

<div class="topic-metadata">

**Author:** [@mattsignorelli](https://discourse.julialang.org/u/mattsignorelli)\
**Replies:** 4\
**Last updated:** [March 17, 2025, 6:56pm UTC](https://discourse.julialang.org/t/metaprogramming-prefer-functions-with-eval-or-macros/127066 "2025-03-17T18:56:31Z")

</div>

In Julia it seems there are two ways one could do code generation within in a package: 1) define a function which calls eval and then call the function within the package module, or 2) define a macro which creates the fu…

---

## [Tensor decompositions in Julia](https://discourse.julialang.org/t/tensor-decompositions-in-julia/112937)

<div class="topic-metadata">

**Author:** [@00krishna](https://discourse.julialang.org/u/00krishna)\
**Replies:** 1\
**Last updated:** [March 17, 2025, 5:56pm UTC](https://discourse.julialang.org/t/tensor-decompositions-in-julia/112937 "2025-03-17T17:56:34Z")

</div>

I was wondering if there is a package for tensor decomposition was in Julia–hopefully the package is differentiable as well for ML. I am talking about CP-decompositions and Tucker decompositions to start. I actually woul…

---

## [Replicating formatting from Fortran code output](https://discourse.julialang.org/t/replicating-formatting-from-fortran-code-output/127036)

<div class="topic-metadata">

**Author:** [@trung](https://discourse.julialang.org/u/trung)\
**Replies:** 6\
**Last updated:** [March 17, 2025, 3:37pm UTC](https://discourse.julialang.org/t/replicating-formatting-from-fortran-code-output/127036 "2025-03-17T15:37:38Z")

</div>

I am trying to replicate the formatting from a Fortran code output in Julia. Here is a MWE. program formattest implicit none integer:: iyd real(4):: d(4),t iyd = 10000 d = 9.999e-38 t = 1.053e10…

---

## [How can I avoid uselessly adding modules to an environment?](https://discourse.julialang.org/t/how-can-i-avoid-uselessly-adding-modules-to-an-environment/125043)

<div class="topic-metadata">

**Author:** [@tb877](https://discourse.julialang.org/u/tb877)\
**Replies:** 10\
**Last updated:** [March 17, 2025, 2:50pm UTC](https://discourse.julialang.org/t/how-can-i-avoid-uselessly-adding-modules-to-an-environment/125043 "2025-03-17T14:50:16Z")

</div>

Sorry for the confusing title, but I wasn’t sure how to say it better. I’m currently developing some code that I’m running on an HPC. In order for the code to be easy to use and reproducible, I’ve made it into a module,…

---

## [GC error / sefgault in a simple C wrapper](https://discourse.julialang.org/t/gc-error-sefgault-in-a-simple-c-wrapper/127032)

<div class="topic-metadata">

**Author:** [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Replies:** 5\
**Last updated:** [March 17, 2025, 1:27pm UTC](https://discourse.julialang.org/t/gc-error-sefgault-in-a-simple-c-wrapper/127032 "2025-03-17T13:27:39Z")

</div>

I am attempting to make a julia wrapper for a C library. The C library is already available as a jll. I was attempting to use Clang.jl to make the wrapper, but whatever I am doing seems to be causing segfaults on garbage…

---

## [When writing code in documenter, how do I comment out bits of text](https://discourse.julialang.org/t/when-writing-code-in-documenter-how-do-i-comment-out-bits-of-text/127016)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 2\
**Last updated:** [March 17, 2025, 12:33pm UTC](https://discourse.julialang.org/t/when-writing-code-in-documenter-how-do-i-comment-out-bits-of-text/127016 "2025-03-17T12:33:06Z")

</div>

Say that i have written a bit of text in my documentation, which I now do not want to be part of that documentation page. However, I do not just want to delete it because I think I might need it again at some point. Is t…

---

## [Writing code that works allocation-free on both vectors and SVectors](https://discourse.julialang.org/t/writing-code-that-works-allocation-free-on-both-vectors-and-svectors/127048)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 6\
**Last updated:** [March 17, 2025, 11:59am UTC](https://discourse.julialang.org/t/writing-code-that-works-allocation-free-on-both-vectors-and-svectors/127048 "2025-03-17T11:59:58Z")

</div>

I’d like to write generic code that operates on abstract vectors, and is non-allocating. A specific example is a function that subtracts the mean and normalizes a vector. This can be done in-place. However, the problem w…

---

## [GLMakie output .pdf or .svg](https://discourse.julialang.org/t/glmakie-output-pdf-or-svg/127051)

<div class="topic-metadata">

**Author:** [@NaSi](https://discourse.julialang.org/u/NaSi)\
**Replies:** 1\
**Last updated:** [March 17, 2025, 11:10am UTC](https://discourse.julialang.org/t/glmakie-output-pdf-or-svg/127051 "2025-03-17T11:10:42Z")

</div>

Hello =) I’m using GLMakie to create 3D plots. I’d like to save these plots as .pdf or .svg files to achieve better quality. When I save them as .png, the resolution isn’t high enough, especially when I zoom in on the a…

---

## [Jl\_alloc\_array\_1d failed when called from python](https://discourse.julialang.org/t/jl-alloc-array-1d-failed-when-called-from-python/127031)

<div class="topic-metadata">

**Author:** [@hartytp](https://discourse.julialang.org/u/hartytp)\
**Replies:** 0\
**Last updated:** [March 16, 2025, 10:35pm UTC](https://discourse.julialang.org/t/jl-alloc-array-1d-failed-when-called-from-python/127031 "2025-03-16T22:35:25Z")

</div>

I’m trying to use the c interface to call Julia code from python, following the “embedding Julia” section of the manual. I’m having issues with jl\_alloc\_array\_1d. As an example, here is a simple c program that runs fine…

---

## [Saving Delaunay Triangulation](https://discourse.julialang.org/t/saving-delaunay-triangulation/127004)

<div class="topic-metadata">

**Author:** [@Varun\_V](https://discourse.julialang.org/u/Varun_V)\
**Replies:** 5\
**Last updated:** [March 16, 2025, 10:20pm UTC](https://discourse.julialang.org/t/saving-delaunay-triangulation/127004 "2025-03-16T22:20:05Z")

</div>

I’d like to save a triangulation I’ve created using DelaunayTriangulation.jl. I have tried using JLD2 but am unable to. I feel like this should be easy so I’m probably doing something wrong. using DelaunayTriangulation,…

---

## [How to instantiate a project in a safe way?](https://discourse.julialang.org/t/how-to-instantiate-a-project-in-a-safe-way/127019)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 2\
**Last updated:** [March 16, 2025, 9:00pm UTC](https://discourse.julialang.org/t/how-to-instantiate-a-project-in-a-safe-way/127019 "2025-03-16T21:00:00Z")

</div>

I am using these scripts for now: #!/bin/bash if \[\[ $(basename $(pwd)) == "bin" \]\]; then cd .. fi export JULIA\_PKG\_SERVER\_REGISTRY\_PREFERENCE=eager julia --project -e 'include("bin/install.jl")' And install.jl lo…

---

## [Best practices about how to hide API Keys in Julia applications](https://discourse.julialang.org/t/best-practices-about-how-to-hide-api-keys-in-julia-applications/127001)

<div class="topic-metadata">

**Author:** [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Replies:** 3\
**Last updated:** [March 16, 2025, 4:42pm UTC](https://discourse.julialang.org/t/best-practices-about-how-to-hide-api-keys-in-julia-applications/127001 "2025-03-16T16:42:31Z")

</div>

The Federal Reserve Bank of St. Louis in the FRED Economic Data website states that: Developers should request a distinct API key for each application they build. All users of an application shall use their own API key…

---

## [Solving nonlinear equations using dual numbers](https://discourse.julialang.org/t/solving-nonlinear-equations-using-dual-numbers/126967)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 16\
**Last updated:** [March 16, 2025, 12:56pm UTC](https://discourse.julialang.org/t/solving-nonlinear-equations-using-dual-numbers/126967 "2025-03-16T12:56:54Z")

</div>

How can I use automated differentiation with NonlinearSolve? I thought it is sufficient to use initial values that are dual numbers. This is not working: if DUAL state\_vec = ForwardDiff.Dual\[Dual(state\_vec\[1\]), Dua…

---

## [Attributes group in RecipesBase](https://discourse.julialang.org/t/attributes-group-in-recipesbase/46809)

<div class="topic-metadata">

**Author:** [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Replies:** 1\
**Last updated:** [March 16, 2025, 12:28pm UTC](https://discourse.julialang.org/t/attributes-group-in-recipesbase/46809 "2025-03-16T12:28:58Z")

</div>

I am trying to set the attribute group for a recipe in Recipes Base.jl. However, it looks like the attribute group is ignored using RecipesBase, Plots @userplot MyPlot @recipe function f(bs::MyPlot) group := bs.args…

---

## [Slicing a Vector into a Matrix using views](https://discourse.julialang.org/t/slicing-a-vector-into-a-matrix-using-views/126918)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 13\
**Last updated:** [March 16, 2025, 11:06am UTC](https://discourse.julialang.org/t/slicing-a-vector-into-a-matrix-using-views/126918 "2025-03-16T11:06:07Z")

</div>

Hi, I loaded data from a simple file input.txt: 1 2 3 4 5 6 7 8 9 into a vector with: data = CSV.File("input.txt", ntasks=1, header=false).Column1 So it’s equivalent to: julia\> data = \[1,2,3,4,5,6,7,8,9\] 9…

---

## [Viewer for PDF images](https://discourse.julialang.org/t/viewer-for-pdf-images/95668)

<div class="topic-metadata">

**Author:** [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Replies:** 34\
**Last updated:** [March 12, 2023, 4:47pm UTC](https://discourse.julialang.org/t/viewer-for-pdf-images/95668 "2023-03-12T16:47:32Z")

</div>

How can I display two PDF images side-by-side for a visual comparison? Background: I run different versions of a model and wish to compare their outputs (Makie plots saved in PDF format). Effectively, I have two direct…

---

## [Help with subtyping semantics](https://discourse.julialang.org/t/help-with-subtyping-semantics/126986)

<div class="topic-metadata">

**Author:** [@Deduction42](https://discourse.julialang.org/u/Deduction42)\
**Replies:** 2\
**Last updated:** [March 15, 2025, 5:09pm UTC](https://discourse.julialang.org/t/help-with-subtyping-semantics/126986 "2025-03-15T17:09:06Z")

</div>

I’m trying to build a type hierarchy around different kinds of units. So far I have this working: abstract type AbstractUnits{D} end abstract type AbstractAffineUnits{D} \<: AbstractUnits{D} end abstract type AbstractSc…

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

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