# General Usage

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

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

**Page:** 222

---

## [Speed comparison on reading a gzip file](https://discourse.julialang.org/t/speed-comparison-on-reading-a-gzip-file/56471)

<div class="topic-metadata">

**Author:** [@calvin](https://discourse.julialang.org/u/calvin)\
**Replies:** 8\
**Last updated:** [December 10, 2023, 8:45pm UTC](https://discourse.julialang.org/t/speed-comparison-on-reading-a-gzip-file/56471 "2023-12-10T20:45:35Z")

</div>

Hi there, perl using shell piping took ~32 seconds. python using shell piping took ~ 36 seconds. julia using shell piping took ~ 70 seconds. julia using GzipDecompressorStream from CodecZlib, which has been recommend…

---

## [Iterative construction of lazy Iterators leads to excessive compilation time](https://discourse.julialang.org/t/iterative-construction-of-lazy-iterators-leads-to-excessive-compilation-time/106766)

<div class="topic-metadata">

**Author:** [@\_cao](https://discourse.julialang.org/u/_cao)\
**Replies:** 21\
**Last updated:** [December 10, 2023, 8:19pm UTC](https://discourse.julialang.org/t/iterative-construction-of-lazy-iterators-leads-to-excessive-compilation-time/106766 "2023-12-10T20:19:00Z")

</div>

I wanted to write an iterator that lazily traverses a graph in breadth first search order, where the graph is defined implicitly by a function giving for each vertex an iterable over the adjacent vertices. This is what I…

---

## [GPU Compilation error when using Lux framework in NeuralPDE](https://discourse.julialang.org/t/gpu-compilation-error-when-using-lux-framework-in-neuralpde/107076)

<div class="topic-metadata">

**Author:** [@Aakhash\_Sundaresan](https://discourse.julialang.org/u/Aakhash_Sundaresan)\
**Replies:** 13\
**Last updated:** [December 10, 2023, 12:58pm UTC](https://discourse.julialang.org/t/gpu-compilation-error-when-using-lux-framework-in-neuralpde/107076 "2023-12-10T12:58:57Z")

</div>

ERROR: LoadError: GPU compilation of MethodInstance for (::GPUArrays.var"#broadcast\_kernel#26")(::CUDA.CuKernelContext, ::CuDeviceMatrix{Float32, 1}, ::Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{2}, Tuple{Base.OneTo{In…

---

## [Parametric struct with key arguments](https://discourse.julialang.org/t/parametric-struct-with-key-arguments/107374)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 1\
**Last updated:** [December 10, 2023, 3:16am UTC](https://discourse.julialang.org/t/parametric-struct-with-key-arguments/107374 "2023-12-10T03:16:17Z")

</div>

struct SortedParticleList{N,M,T\<:Unsigned} storage::SVector{N,T} end Here we have a parametric struct with three position arguments. I can have SortedParticleList{N} and SortedParticleList{N, M} and SortedParti…

---

## [Thread safe buffer which blocks retrieval when empty?](https://discourse.julialang.org/t/thread-safe-buffer-which-blocks-retrieval-when-empty/107352)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 11\
**Last updated:** [December 9, 2023, 11:16pm UTC](https://discourse.julialang.org/t/thread-safe-buffer-which-blocks-retrieval-when-empty/107352 "2023-12-09T23:16:50Z")

</div>

Does anyone know of a package which implements a (circular) buffer that blocks when popping from it if it’s empty? To give a bit more context, below is a MWE for a program which has one thread running and continuously f…

---

## [Best way to root a pipeline directory structure inside of a package](https://discourse.julialang.org/t/best-way-to-root-a-pipeline-directory-structure-inside-of-a-package/107275)

<div class="topic-metadata">

**Author:** [@cdawg](https://discourse.julialang.org/u/cdawg)\
**Replies:** 9\
**Last updated:** [December 9, 2023, 7:44pm UTC](https://discourse.julialang.org/t/best-way-to-root-a-pipeline-directory-structure-inside-of-a-package/107275 "2023-12-09T19:44:15Z")

</div>

I’ve written some bioinformatics analysis scripts in julia. They are fast and impressed everyone! :heart\_eyes: Now I would like to share them with my collaborators. They act inside a pipeline that took many years to deve…

---

## [Why does Julia support \`::Vector \* ::Matrix\`?](https://discourse.julialang.org/t/why-does-julia-support-vector-matrix/107330)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 7\
**Last updated:** [December 9, 2023, 3:46pm UTC](https://discourse.julialang.org/t/why-does-julia-support-vector-matrix/107330 "2023-12-09T15:46:41Z")

</div>

For example, julia\> \[1,2\] \* \[2;;\] 2×1 Matrix{Int64}: 2 4 This reshapes the vector as a n x 1 matrix and multiplies it with the 1 x 1 matrix. This seems to go against the general idea of treating Vectors and Matrices …

---

## [Difference between '::UInt64' and '::Type(UInt64)'](https://discourse.julialang.org/t/difference-between-uint64-and-type-uint64/107355)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 1\
**Last updated:** [December 9, 2023, 12:02pm UTC](https://discourse.julialang.org/t/difference-between-uint64-and-type-uint64/107355 "2023-12-09T12:02:44Z")

</div>

I saw functions defined as function check\_bitstring\_typeparams(::Val{B}, ::Val{1}, ::Type{UInt64}) where {B} if B \> 64 error("$B bits do not fit into a 64-bit chunk") end end What is the difference betw…

---

## [Is 'SVector' a keyword in julia?](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 10\
**Last updated:** [December 8, 2023, 11:48pm UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306 "2023-12-08T23:48:31Z")

</div>

In a package, I see a lot of ‘SVector’. It looks like a datatype. But I cannot find it by help. help?\> SVector search: DenseVector SparseVector AbstractVector StridedVector AbstractSparseVector DenseVecOrMat Couldn't f…

---

## [Unique (indices) method similar to MATLAB](https://discourse.julialang.org/t/unique-indices-method-similar-to-matlab/34446)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 7\
**Last updated:** [December 8, 2023, 10:43pm UTC](https://discourse.julialang.org/t/unique-indices-method-similar-to-matlab/34446 "2023-12-08T22:43:15Z")

</div>

Is there a method in Julia similar to MATLAB’s unique method? In Julia there is unique, but it does not have the same functionality. Specifically, I would like to get the list of indices of unique elements. julia\> uniqu…

---

## [Providing initial values in init\_params for compositional sampling](https://discourse.julialang.org/t/providing-initial-values-in-init-params-for-compositional-sampling/107348)

<div class="topic-metadata">

**Author:** [@ph-rast](https://discourse.julialang.org/u/ph-rast)\
**Replies:** 0\
**Last updated:** [December 8, 2023, 9:47pm UTC](https://discourse.julialang.org/t/providing-initial-values-in-init-params-for-compositional-sampling/107348 "2023-12-08T21:47:00Z")

</div>

Hi there, when I’m passing initial values init\_vals = \[A, init\_beta, init\_eta, init\_sigma, init\_z\] to the init\_params argumenet in sampling() everything works as expected: chain = sample(model, HMC(), MCMCThreads, ... …

---

## [MATLAB-like \`unique\` where you can recreate the original with indices](https://discourse.julialang.org/t/matlab-like-unique-where-you-can-recreate-the-original-with-indices/77968)

<div class="topic-metadata">

**Author:** [@iamed2](https://discourse.julialang.org/u/iamed2)\
**Replies:** 8\
**Last updated:** [December 8, 2023, 8:05pm UTC](https://discourse.julialang.org/t/matlab-like-unique-where-you-can-recreate-the-original-with-indices/77968 "2023-12-08T20:05:30Z")

</div>

Is there an implementation of the MATLAB 3-output unique in Julia? In particular I’m looking for an efficient way to recreate the original input from the unique elements, like C(ic) in MATLAB. Previous discussions have…

---

## [How to convert Vector of Vectors to Matrix](https://discourse.julialang.org/t/how-to-convert-vector-of-vectors-to-matrix/72609)

<div class="topic-metadata">

**Author:** [@XLVII](https://discourse.julialang.org/u/XLVII)\
**Replies:** 39\
**Last updated:** [December 8, 2023, 7:57pm UTC](https://discourse.julialang.org/t/how-to-convert-vector-of-vectors-to-matrix/72609 "2023-12-08T19:57:34Z")

</div>

I have a vector = \[\[1,0,1\],\[ 0,0,1\]\] I am trying to convert this to → \[ 1 0 1 ; 0 0 1 \] How?

---

## [Different \`@code\_llvm\` output on macos and x86](https://discourse.julialang.org/t/different-code-llvm-output-on-macos-and-x86/107338)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 4\
**Last updated:** [December 8, 2023, 7:17pm UTC](https://discourse.julialang.org/t/different-code-llvm-output-on-macos-and-x86/107338 "2023-12-08T19:17:31Z")

</div>

Hi, I wonder about the different outputs I obtain from @code\_llvm with the same Julia version (1.10.rc2) on different architectures (arm vs x86). The following script: f(a,b) = a .+ b f (generic function with 1 method…

---

## [Safe to interrupt precompilation?](https://discourse.julialang.org/t/safe-to-interrupt-precompilation/107339)

<div class="topic-metadata">

**Author:** [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Replies:** 2\
**Last updated:** [December 8, 2023, 6:17pm UTC](https://discourse.julialang.org/t/safe-to-interrupt-precompilation/107339 "2023-12-08T18:17:45Z")

</div>

If precompilation starts (e.g. when I load an environment or add a package to an environment), is it safe to interrupt that with Ctrl+c (or some other method), if I know I am going to perform another action which is goin…

---

## [Plots.jl | Heatmap legend is cut off or lays on top of the colorbar ticks](https://discourse.julialang.org/t/plots-jl-heatmap-legend-is-cut-off-or-lays-on-top-of-the-colorbar-ticks/107329)

<div class="topic-metadata">

**Author:** [@lenardj](https://discourse.julialang.org/u/lenardj)\
**Replies:** 1\
**Last updated:** [December 8, 2023, 4:44pm UTC](https://discourse.julialang.org/t/plots-jl-heatmap-legend-is-cut-off-or-lays-on-top-of-the-colorbar-ticks/107329 "2023-12-08T16:44:27Z")

</div>

I am using the heatmap function in Plots.jl to plot densities in a plane. The colorbar should have a legend with an explanation “…”. I use the following code: Heatmap = heatmap!(x,y,HeatmapData, c = :thermal,xlabel = “…

---

## [Looping over a thousand files and checking if empty](https://discourse.julialang.org/t/looping-over-a-thousand-files-and-checking-if-empty/107291)

<div class="topic-metadata">

**Author:** [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Replies:** 15\
**Last updated:** [December 8, 2023, 4:39pm UTC](https://discourse.julialang.org/t/looping-over-a-thousand-files-and-checking-if-empty/107291 "2023-12-08T16:39:31Z")

</div>

Hello! I have some results of an experiment. They are stored inside a folder and I need to open the files, check what is the fraction of missing values inside a file and tag it according to different level of missing va…

---

## [How to release lock on Arrow table](https://discourse.julialang.org/t/how-to-release-lock-on-arrow-table/107046)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 7\
**Last updated:** [December 8, 2023, 2:23pm UTC](https://discourse.julialang.org/t/how-to-release-lock-on-arrow-table/107046 "2023-12-08T14:23:01Z")

</div>

I need to read in an Arrow file, combine some data, and then overwrite that file. That means I need to release the file lock that happens when you read. How can I guarantee to release that lock? I’ve read that clearing o…

---

## [System image with PyPlot.jl](https://discourse.julialang.org/t/system-image-with-pyplot-jl/107320)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 4\
**Last updated:** [December 8, 2023, 12:00pm UTC](https://discourse.julialang.org/t/system-image-with-pyplot-jl/107320 "2023-12-08T12:00:06Z")

</div>

I created a small project, see: GitHub - ufechner7/Tethers.jl: Tether models For now the code is trivial, but to avoid high time-to-first plot I created a custom system image with ModelingToolkit, OrdinaryDiffEq, and P…

---

## [Any way to multiple dispatch on functions?\`](https://discourse.julialang.org/t/any-way-to-multiple-dispatch-on-functions/107318)

<div class="topic-metadata">

**Author:** [@Jad\_Zeitouni](https://discourse.julialang.org/u/Jad_Zeitouni)\
**Replies:** 7\
**Last updated:** [December 8, 2023, 9:50am UTC](https://discourse.julialang.org/t/any-way-to-multiple-dispatch-on-functions/107318 "2023-12-08T09:50:01Z")

</div>

I defined two abstract types, call them MyType and MyFrozenType{T\<:MyType}. Subtypes SpecificFrozenType \<: MyFrozenStruct{SpecificType} are usually defined as SpecificFrozenType(x::SpecificType, v::Vector) Now, I have …

---

## [Parametric types and StaticArrays](https://discourse.julialang.org/t/parametric-types-and-staticarrays/107312)

<div class="topic-metadata">

**Author:** [@jondavis847](https://discourse.julialang.org/u/jondavis847)\
**Replies:** 2\
**Last updated:** [December 8, 2023, 9:27am UTC](https://discourse.julialang.org/t/parametric-types-and-staticarrays/107312 "2023-12-08T09:27:22Z")

</div>

As I’ve worked through a couple projects now, I realized I don’t fully understand the nuances of parametric types, and specifically when used with StaticArrays. My goal of course is to get all the performance I can, but …

---

## [Write a table into SQLite and DuckDB in efficient manner](https://discourse.julialang.org/t/write-a-table-into-sqlite-and-duckdb-in-efficient-manner/93417)

<div class="topic-metadata">

**Author:** [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Replies:** 24\
**Last updated:** [December 8, 2023, 3:25am UTC](https://discourse.julialang.org/t/write-a-table-into-sqlite-and-duckdb-in-efficient-manner/93417 "2023-12-08T03:25:25Z")

</div>

How can I efficiently populate DB table from very long tables (say, millions rows)? I try to compare SQlite vs DuckDB in this scenario, but I think I’m doing this very inefficiently: using SQLite, DuckDB, Tables con\_sq…

---

## [Software references in the code but the ref is ignored by the compiler](https://discourse.julialang.org/t/software-references-in-the-code-but-the-ref-is-ignored-by-the-compiler/107311)

<div class="topic-metadata">

**Author:** [@skypuppy](https://discourse.julialang.org/u/skypuppy)\
**Replies:** 0\
**Last updated:** [December 8, 2023, 3:08am UTC](https://discourse.julialang.org/t/software-references-in-the-code-but-the-ref-is-ignored-by-the-compiler/107311 "2023-12-08T03:08:04Z")

</div>

It occurred to me today, while doing a little a little catch-up of the forum, how convenient it would be to have a reference remark (meta-bookmark?), or pointer to a function, variable, or “unreadable” code embedded righ…

---

## [Function name like ‘SMatrix{N,N}’](https://discourse.julialang.org/t/function-name-like-smatrix-n-n/107309)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 1\
**Last updated:** [December 8, 2023, 2:59am UTC](https://discourse.julialang.org/t/function-name-like-smatrix-n-n/107309 "2023-12-08T02:59:32Z")

</div>

The following is a script from here. We see code SA = SMatrix{N,N}(A) Is it ok for a function name to contain the curly brackets? I guess ‘SMatrix{N,N}’ is a function, right? using BenchmarkTools using LinearAlgebra u…

---

## [Automatic differentiation for Complex output w.r.t to Real inputs taking too long compared to the function evaluation](https://discourse.julialang.org/t/automatic-differentiation-for-complex-output-w-r-t-to-real-inputs-taking-too-long-compared-to-the-function-evaluation/107288)

<div class="topic-metadata">

**Author:** [@KapilKhanal](https://discourse.julialang.org/u/KapilKhanal)\
**Replies:** 3\
**Last updated:** [December 8, 2023, 1:53am UTC](https://discourse.julialang.org/t/automatic-differentiation-for-complex-output-w-r-t-to-real-inputs-taking-too-long-compared-to-the-function-evaluation/107288 "2023-12-08T01:53:16Z")

</div>

I am using Zygote for differentiating a complex output with respect to 3 real inputs. The function evaluation itself takes about 0.088371 seconds (146.12 k allocations: 10.071 MiB, 99.23% compilation time) but the grad…

---

## [Making sorting a tree represented by vector of any types faster](https://discourse.julialang.org/t/making-sorting-a-tree-represented-by-vector-of-any-types-faster/106998)

<div class="topic-metadata">

**Author:** [@dgsob](https://discourse.julialang.org/u/dgsob)\
**Replies:** 1\
**Last updated:** [December 7, 2023, 11:04pm UTC](https://discourse.julialang.org/t/making-sorting-a-tree-represented-by-vector-of-any-types-faster/106998 "2023-12-07T23:04:52Z")

</div>

I have an algorithm that generates a tree by multiplying two functions. It works, but my goal is to make it faster. With profiling I’ve found that a substantial amount of time is spend on sorting. I’m wondering if the s…

---

## [Should passing Val(dims) to cat be better documented?](https://discourse.julialang.org/t/should-passing-val-dims-to-cat-be-better-documented/107294)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 1\
**Last updated:** [December 7, 2023, 7:34pm UTC](https://discourse.julialang.org/t/should-passing-val-dims-to-cat-be-better-documented/107294 "2023-12-07T19:34:31Z")

</div>

Would documenting the reason for passing Val(dims) to to the dims keyword of cat lead to more purrfect documentation than what we have meow? Currently the documentation for cat indicates that one can pass a Val to dims…

---

## [How to dynamically embed Julia in a Windows app](https://discourse.julialang.org/t/how-to-dynamically-embed-julia-in-a-windows-app/107133)

<div class="topic-metadata">

**Author:** [@droodman](https://discourse.julialang.org/u/droodman)\
**Replies:** 15\
**Last updated:** [December 7, 2023, 7:29pm UTC](https://discourse.julialang.org/t/how-to-dynamically-embed-julia-in-a-windows-app/107133 "2023-12-07T19:29:20Z")

</div>

I have written a plugin for the commercial statistical software Stata that bridges to Julia in order to exploit its speed. In an issue thread on juliaup, @davidanthoff and @staticfloat have helped me figure out how best …

---

## [Loop performance issue for a specific data size](https://discourse.julialang.org/t/loop-performance-issue-for-a-specific-data-size/107021)

<div class="topic-metadata">

**Author:** [@ReWoP](https://discourse.julialang.org/u/ReWoP)\
**Replies:** 2\
**Last updated:** [December 7, 2023, 6:10pm UTC](https://discourse.julialang.org/t/loop-performance-issue-for-a-specific-data-size/107021 "2023-12-07T18:10:07Z")

</div>

Hello everyone! I’m testing a population-based algorithm and have encountered performance issues, particularly when looping with large populations (i.e., using large data matrices). Everything works fine when using mat…

---

## [SMatrix static slice](https://discourse.julialang.org/t/smatrix-static-slice/107223)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [December 6, 2023, 6:17pm UTC](https://discourse.julialang.org/t/smatrix-static-slice/107223 "2023-12-06T18:17:27Z")

</div>

Is StaticArrays.SUnitRange (which is internal, cf StaticArrays.jl#474) the only way to get static slices for dimensions known at compile time? MWE: julia\> using StaticArrays julia\> A = one(SMatrix{4,4}) 4×4 SMatrix{4,…

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

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