# General Usage

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

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

**Page:** 461

---

## [Help optimizing 1000x Zygote overhead for linear interpolation](https://discourse.julialang.org/t/help-optimizing-1000x-zygote-overhead-for-linear-interpolation/79549)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 3\
**Last updated:** [April 15, 2022, 11:16pm UTC](https://discourse.julialang.org/t/help-optimizing-1000x-zygote-overhead-for-linear-interpolation/79549 "2022-04-15T23:16:35Z")

</div>

I need to compute a gradient of an interpolation w.r.t. to the knot y-positions. None of the standard packages seemed to work with Zygote so I coded this very simple MWE: using Zygote, ForwardDiff, BenchmarkTools funct…

---

## [Matrix free GMRES with structs?](https://discourse.julialang.org/t/matrix-free-gmres-with-structs/79364)

<div class="topic-metadata">

**Author:** [@Srikumar](https://discourse.julialang.org/u/Srikumar)\
**Replies:** 3\
**Last updated:** [April 15, 2022, 9:36pm UTC](https://discourse.julialang.org/t/matrix-free-gmres-with-structs/79364 "2022-04-15T21:36:05Z")

</div>

I am wondering if there is a way to solve Ax=b with GMRES where x is not a regular vector but a struct consisting of different vectors? A is available as a linearmap/function but I am not how to use GMRES here since x is…

---

## [Flattening Tuples of Types that form the parameter of a supertype](https://discourse.julialang.org/t/flattening-tuples-of-types-that-form-the-parameter-of-a-supertype/79528)

<div class="topic-metadata">

**Author:** [@Dhruva2](https://discourse.julialang.org/u/Dhruva2)\
**Replies:** 2\
**Last updated:** [April 15, 2022, 6:06pm UTC](https://discourse.julialang.org/t/flattening-tuples-of-types-that-form-the-parameter-of-a-supertype/79528 "2022-04-15T18:06:13Z")

</div>

Dear all, Below is an MWE of the code I’m writing. I’m using the abstract supertype Pairer as a ‘tag’. Its two type parameters specify the ionic inputs and outputs to concrete subtypes. Joiner and Extender make new c…

---

## [How to use the \`by\` argument to \`searchsortedlast()\`](https://discourse.julialang.org/t/how-to-use-the-by-argument-to-searchsortedlast/79509)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 3\
**Last updated:** [April 15, 2022, 8:13am UTC](https://discourse.julialang.org/t/how-to-use-the-by-argument-to-searchsortedlast/79509 "2022-04-15T08:13:37Z")

</div>

I am trying to find the index of the last element of a such that f(a) \<= 10. You can do this with findlast: julia\> a = \[1, 2, 3, 4, 5\] 5-element Vector{Int64}: 1 2 3 4 5 julia\> findlast(x -\> x^2 ≤ 10, a) 3 Howeve…

---

## [How can I package julia program with dependencies using PackageCompiler?](https://discourse.julialang.org/t/how-can-i-package-julia-program-with-dependencies-using-packagecompiler/79373)

<div class="topic-metadata">

**Author:** [@Supernova](https://discourse.julialang.org/u/Supernova)\
**Replies:** 3\
**Last updated:** [April 15, 2022, 7:36am UTC](https://discourse.julialang.org/t/how-can-i-package-julia-program-with-dependencies-using-packagecompiler/79373 "2022-04-15T07:36:52Z")

</div>

I’m trying to package my Julia program with PackageCompiler, but I met a problem of dependencies. I tried the simplest demo of MyApp as Apps · PackageCompiler (julialang.github.io) showed, and it worked normally. Howeve…

---

## [Using AWSS3.jl getting the following error](https://discourse.julialang.org/t/using-awss3-jl-getting-the-following-error/79497)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 1\
**Last updated:** [April 14, 2022, 4:51pm UTC](https://discourse.julialang.org/t/using-awss3-jl-getting-the-following-error/79497 "2022-04-14T16:51:34Z")

</div>

Hi all :slight\_smile: I’m debugging this error now for a while. I think it’s related with a different post I made a while ago. So I’m using a couple of threads to do stuff async. Once in while the main/ starting thread…

---

## [Why passing a distributed matrix to functions hurts performance?](https://discourse.julialang.org/t/why-passing-a-distributed-matrix-to-functions-hurts-performance/79353)

<div class="topic-metadata">

**Author:** [@Neo](https://discourse.julialang.org/u/Neo)\
**Replies:** 7\
**Last updated:** [April 14, 2022, 8:19pm UTC](https://discourse.julialang.org/t/why-passing-a-distributed-matrix-to-functions-hurts-performance/79353 "2022-04-14T20:19:00Z")

</div>

Hi folks, I observed something strange recently. Passing a distributed matrix to a function will hurt its performance? Let’s say here is task to apply a distributed matrix to some vectors like below: using Distributed…

---

## [Minimizing allocations for custom powerset iterator](https://discourse.julialang.org/t/minimizing-allocations-for-custom-powerset-iterator/79361)

<div class="topic-metadata">

**Author:** [@RobertGregg](https://discourse.julialang.org/u/RobertGregg)\
**Replies:** 7\
**Last updated:** [April 14, 2022, 7:28pm UTC](https://discourse.julialang.org/t/minimizing-allocations-for-custom-powerset-iterator/79361 "2022-04-14T19:28:22Z")

</div>

Just to preface: I realize both Combinatorics.jl and IterTools.jl implement an iterator for powersets. This question is mostly for improving my own Julia skills. I’m trying to iterate through a powerset as efficiently a…

---

## [C-Compatible Julia Function](https://discourse.julialang.org/t/c-compatible-julia-function/79458)

<div class="topic-metadata">

**Author:** [@Yinmin\_Liu](https://discourse.julialang.org/u/Yinmin_Liu)\
**Replies:** 8\
**Last updated:** [April 14, 2022, 7:27pm UTC](https://discourse.julialang.org/t/c-compatible-julia-function/79458 "2022-04-14T19:27:14Z")

</div>

Hi, According to the ccall doc, it is possible to pass Julia functions to native C functions. But how should I program my Julia function, when the C function need an input function with void return type and take a point…

---

## [LinearMaps.jl](https://discourse.julialang.org/t/linearmaps-jl/79413)

<div class="topic-metadata">

**Author:** [@Srikumar](https://discourse.julialang.org/u/Srikumar)\
**Replies:** 7\
**Last updated:** [April 14, 2022, 6:08pm UTC](https://discourse.julialang.org/t/linearmaps-jl/79413 "2022-04-14T18:08:21Z")

</div>

Is it possible to use Linearmaps on custom data types? I have a struct data type v and wish to construct a function wrapped linear map A that can act on v like A\*v. Would love to know how I could do this! Thanks in adva…

---

## [Deleting row and column from an array](https://discourse.julialang.org/t/deleting-row-and-column-from-an-array/28969)

<div class="topic-metadata">

**Author:** [@mamuniut09](https://discourse.julialang.org/u/mamuniut09)\
**Replies:** 8\
**Last updated:** [April 14, 2022, 3:24pm UTC](https://discourse.julialang.org/t/deleting-row-and-column-from-an-array/28969 "2022-04-14T15:24:37Z")

</div>

Hello all, I wanted to remove column and row from an array, but couldn’t find any function to do that. For example, if I want to remove the second row and second column from the following array, how can I do that? a=\[1…

---

## [Constrained Optimization and Constraints with more than one variable](https://discourse.julialang.org/t/constrained-optimization-and-constraints-with-more-than-one-variable/79482)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 4\
**Last updated:** [April 14, 2022, 1:00pm UTC](https://discourse.julialang.org/t/constrained-optimization-and-constraints-with-more-than-one-variable/79482 "2022-04-14T13:00:42Z")

</div>

Hello everyone, I want to use Optim.jl to solve a constrained optimization problem. As far as I understand, Optim.jl offers constraints of the form (lower\_bound\_i \<= x\_i \<= upper\_bound\_i). However, for my problem I need…

---

## [Can't load package (StatsBase) in Jupyter notebook but can in REPL](https://discourse.julialang.org/t/cant-load-package-statsbase-in-jupyter-notebook-but-can-in-repl/77095)

<div class="topic-metadata">

**Author:** [@rwgardner](https://discourse.julialang.org/u/rwgardner)\
**Replies:** 7\
**Last updated:** [April 14, 2022, 11:41am UTC](https://discourse.julialang.org/t/cant-load-package-statsbase-in-jupyter-notebook-but-can-in-repl/77095 "2022-04-14T11:41:10Z")

</div>

I have a fresh installation of julia-1.6.5 on an ubuntu 18.04 box. I added a number of packages and in the REPL, I can julia\> using StatsBase \[ Info: Precompiling StatsBase \[2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91\] Succe…

---

## [Use of Openlibm](https://discourse.julialang.org/t/use-of-openlibm/79473)

<div class="topic-metadata">

**Author:** [@Shreya\_Gupta](https://discourse.julialang.org/u/Shreya_Gupta)\
**Replies:** 1\
**Last updated:** [April 14, 2022, 8:56am UTC](https://discourse.julialang.org/t/use-of-openlibm/79473 "2022-04-14T08:56:21Z")

</div>

Hello Julia community, I am working on a project(written in C/C++,Octave) where I have to make the C math library function work consistently across compilers and operating systems. For this, One solution that comes is th…

---

## [Performance of \`zero\`, \`oneunit\` etc. in constructing unsigned ranges](https://discourse.julialang.org/t/performance-of-zero-oneunit-etc-in-constructing-unsigned-ranges/79470)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 5\
**Last updated:** [April 14, 2022, 7:26am UTC](https://discourse.julialang.org/t/performance-of-zero-oneunit-etc-in-constructing-unsigned-ranges/79470 "2022-04-14T07:26:32Z")

</div>

In my code, I often need to iterate over the range 0:m or 1:m where the type of each range element is a primitive type T, usually UInt8 or UInt16. m itself is already of type T. This leaves me with many options for spe…

---

## [How to speed up the for-loop with dataframe access](https://discourse.julialang.org/t/how-to-speed-up-the-for-loop-with-dataframe-access/79447)

<div class="topic-metadata">

**Author:** [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Replies:** 25\
**Last updated:** [April 14, 2022, 6:44am UTC](https://discourse.julialang.org/t/how-to-speed-up-the-for-loop-with-dataframe-access/79447 "2022-04-14T06:44:18Z")

</div>

Hi, I am new to Julia from R, and I have a little trouble in learning how to speed up my code. for a simple demo example, I have a DataFrame with 3 column X 8679568 row, each row is a record of protein pair. The row 1 …

---

## [Error update any packages in julia1.7.1](https://discourse.julialang.org/t/error-update-any-packages-in-julia1-7-1/73578)

<div class="topic-metadata">

**Author:** [@samuel\_Yi](https://discourse.julialang.org/u/samuel_Yi)\
**Replies:** 2\
**Last updated:** [April 14, 2022, 5:40am UTC](https://discourse.julialang.org/t/error-update-any-packages-in-julia1-7-1/73578 "2022-04-14T05:40:29Z")

</div>

Info: julia\> using InteractiveUtils; versioninfo() Julia Version 1.7.1 Commit ac5cc99908 (2021-12-22 19:35 UTC) Platform Info: OS: Windows (x86\_64-w64-mingw32) CPU: Intel(R) Core™ i7-8700 CPU @ 3.20GHz WORD\_SIZE: 64 LIB…

---

## [Trouble passing struct to C function](https://discourse.julialang.org/t/trouble-passing-struct-to-c-function/79403)

<div class="topic-metadata">

**Author:** [@Octogonapus](https://discourse.julialang.org/u/Octogonapus)\
**Replies:** 7\
**Last updated:** [April 13, 2022, 11:47pm UTC](https://discourse.julialang.org/t/trouble-passing-struct-to-c-function/79403 "2022-04-13T23:47:24Z")

</div>

I am trying to wrap a JLL I’m authoring and as part of creating the wrapper, I’m writing some tests. In this test, I create an instance of a struct: conn\_options = Ref(aws\_mqtt\_connection\_options( host\_name\_cur\[\], …

---

## [Concatenate csv files without loading them](https://discourse.julialang.org/t/concatenate-csv-files-without-loading-them/35527)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 10\
**Last updated:** [April 13, 2022, 9:56pm UTC](https://discourse.julialang.org/t/concatenate-csv-files-without-loading-them/35527 "2022-04-13T21:56:20Z")

</div>

I’m wondering what the best way would be to concatenate multiple CSV files – all of which contain the same header row (they are compatible) – into one CSV file. I know I can do something like (taken from @Chris\_Foster’s…

---

## [What is the fastest, vector or array?](https://discourse.julialang.org/t/what-is-the-fastest-vector-or-array/79399)

<div class="topic-metadata">

**Author:** [@Leticia-maria](https://discourse.julialang.org/u/Leticia-maria)\
**Replies:** 4\
**Last updated:** [April 13, 2022, 8:42pm UTC](https://discourse.julialang.org/t/what-is-the-fastest-vector-or-array/79399 "2022-04-13T20:42:18Z")

</div>

Hi there, I would like to know what do you think about the performance of different types: vector and array. Whic one is the fastest?

---

## [Proper declaration of function accepting Dicts with mixed number types](https://discourse.julialang.org/t/proper-declaration-of-function-accepting-dicts-with-mixed-number-types/79184)

<div class="topic-metadata">

**Author:** [@fergu](https://discourse.julialang.org/u/fergu)\
**Replies:** 13\
**Last updated:** [April 13, 2022, 6:26pm UTC](https://discourse.julialang.org/t/proper-declaration-of-function-accepting-dicts-with-mixed-number-types/79184 "2022-04-13T18:26:45Z")

</div>

I have a function that accepts a dictionary as input where the arguments will always be string keys with values that are a vector of real numbers. They may in practice be integers or floats or whatever. What is important…

---

## [Should broadcasting be avoided for type unstable code?](https://discourse.julialang.org/t/should-broadcasting-be-avoided-for-type-unstable-code/79438)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 3\
**Last updated:** [April 13, 2022, 3:55pm UTC](https://discourse.julialang.org/t/should-broadcasting-be-avoided-for-type-unstable-code/79438 "2022-04-13T15:55:35Z")

</div>

This simple expression incurs an overhead of 0.13 seconds in a fresh REPL (Julia 1.7.1). julia\> @time (x -\> x .+ 1)(Any\[2\]) 0.128635 seconds (458.42 k allocations: 25.632 MiB, 11.29% gc time, 99.23% compilation time) …

---

## [Can I unexport something?](https://discourse.julialang.org/t/can-i-unexport-something/79436)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 3\
**Last updated:** [April 13, 2022, 3:55pm UTC](https://discourse.julialang.org/t/can-i-unexport-something/79436 "2022-04-13T15:55:01Z")

</div>

I’m using a macro which exports something that I don’t want exported. Is there some Base.DarkMagic.\_remove\_export\_binding\_assuming\_P\_eq\_NP function I can use for that?

---

## [How to make type parameter for \`Tuple\` represent both abstract type and concrete type?](https://discourse.julialang.org/t/how-to-make-type-parameter-for-tuple-represent-both-abstract-type-and-concrete-type/79420)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 3\
**Last updated:** [April 13, 2022, 3:23pm UTC](https://discourse.julialang.org/t/how-to-make-type-parameter-for-tuple-represent-both-abstract-type-and-concrete-type/79420 "2022-04-13T15:23:24Z")

</div>

julia\> t1 = NTuple{2, Real} Tuple{Real, Real} julia\> t2 = NTuple{2, T} where {T\<:Real} Tuple{T, T} where T\<:Real julia\> t1 \<: t2 false julia\> t3 = NTuple{2, \<:T} where {T\<:Real} Tuple{var"#s1", var"#s1"} where {T\<:Rea…

---

## [Julia V1.7 about JuMP](https://discourse.julialang.org/t/julia-v1-7-about-jump/79433)

<div class="topic-metadata">

**Author:** [@EdBa](https://discourse.julialang.org/u/EdBa)\
**Replies:** 0\
**Last updated:** [April 13, 2022, 11:58am UTC](https://discourse.julialang.org/t/julia-v1-7-about-jump/79433 "2022-04-13T11:58:28Z")

</div>

Hello, Something strange just happened. I was working using JuMP since few days and now it’s a bug. Is there any explanation? how can I fix the problem? This is the error message I got: Failed to precompile JuMP \[4076…

---

## [What do you think? add a callback to Documents.Page() to allow modification of \*.md pages on the fly before parsing](https://discourse.julialang.org/t/what-do-you-think-add-a-callback-to-documents-page-to-allow-modification-of-md-pages-on-the-fly-before-parsing/79217)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 10\
**Last updated:** [April 13, 2022, 9:53am UTC](https://discourse.julialang.org/t/what-do-you-think-add-a-callback-to-documents-page-to-allow-modification-of-md-pages-on-the-fly-before-parsing/79217 "2022-04-13T09:53:22Z")

</div>

Hello, for my project I need to add some common parts to the markdown files that will be processed by Documenter.jl to become HTML pages, like a footer section to add a @raw html block to allow comments, a sort of heade…

---

## [Combining @sync and @async with for and while loops](https://discourse.julialang.org/t/combining-sync-and-async-with-for-and-while-loops/79424)

<div class="topic-metadata">

**Author:** [@Tine](https://discourse.julialang.org/u/Tine)\
**Replies:** 0\
**Last updated:** [April 13, 2022, 9:44am UTC](https://discourse.julialang.org/t/combining-sync-and-async-with-for-and-while-loops/79424 "2022-04-13T09:44:33Z")

</div>

I am relatively new to Julia, and I am trying to understand the @sync and @async macro, and how they act when combined with for and while loops. I wonder if someone could tell me what the difference between these two ar…

---

## [Convert hash digest to UInt256](https://discourse.julialang.org/t/convert-hash-digest-to-uint256/79307)

<div class="topic-metadata">

**Author:** [@jj-404](https://discourse.julialang.org/u/jj-404)\
**Replies:** 11\
**Last updated:** [April 13, 2022, 8:37am UTC](https://discourse.julialang.org/t/convert-hash-digest-to-uint256/79307 "2022-04-13T08:37:45Z")

</div>

Hello guys, I need to convert the output of sha256 to a UInt256. What is the optimal way to do that performance-wise? using SHA, BitIntegers x=sha256("okok") # convert(UInt256, x) for context, sha256 returns a Vector{…

---

## [Iterating on Tuple allocates memory if values don't have identical types](https://discourse.julialang.org/t/iterating-on-tuple-allocates-memory-if-values-dont-have-identical-types/79410)

<div class="topic-metadata">

**Author:** [@jdebecdelievre](https://discourse.julialang.org/u/jdebecdelievre)\
**Replies:** 4\
**Last updated:** [April 13, 2022, 6:56am UTC](https://discourse.julialang.org/t/iterating-on-tuple-allocates-memory-if-values-dont-have-identical-types/79410 "2022-04-13T06:56:39Z")

</div>

Hi, Could someone help me understand why iterating on a tuple seems much slower if the values have non-unique types? Here is a very simple example: a = 1. b = \[1.\] c = \[1.\] A = (a, b) B = (b, c) @btime for d=$A; d; en…

---

## [Enforcing dependencies in my own package](https://discourse.julialang.org/t/enforcing-dependencies-in-my-own-package/16967)

<div class="topic-metadata">

**Author:** [@macroscian](https://discourse.julialang.org/u/macroscian)\
**Replies:** 9\
**Last updated:** [April 13, 2022, 6:34am UTC](https://discourse.julialang.org/t/enforcing-dependencies-in-my-own-package/16967 "2022-04-13T06:34:23Z")

</div>

I’m trying to write a package (my first, so apologies for ignorance) using Julia 1.0.1 that depends on the master version of an existing package Pages.jl, but am struggling to enforce this. My current method is, in REP…

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

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