# Performance

**URL:** https://discourse.julialang.org/c/usage/perf/37.md?page=131

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

**Page:** 132

---

## [Creating an iterator by wrapping another one](https://discourse.julialang.org/t/creating-an-iterator-by-wrapping-another-one/22280)

<div class="topic-metadata">

**Author:** [@fverdugo](https://discourse.julialang.org/u/fverdugo)\
**Replies:** 9\
**Last updated:** [March 26, 2019, 7:00am UTC](https://discourse.julialang.org/t/creating-an-iterator-by-wrapping-another-one/22280 "2019-03-26T07:00:43Z")

</div>

I am trying to create an iterator that wraps another one. Let us assume that we have this iterator that returns l times the array a : struct Foo a::Array{Float64,1} l::Int end Base.iterate(foo::Foo) = iterate(f…

---

## ["Functional State" Iterators & Why isn't this loop as fast as entitlement?](https://discourse.julialang.org/t/functional-state-iterators-why-isnt-this-loop-as-fast-as-entitlement/22282)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 5\
**Last updated:** [March 25, 2019, 12:05pm UTC](https://discourse.julialang.org/t/functional-state-iterators-why-isnt-this-loop-as-fast-as-entitlement/22282 "2019-03-25T12:05:09Z")

</div>

TLDR High level iterators (values(dict), etc.) are potentially \>3x slower than they could be… Why and how could they be improved? Let me lead with the real near term question: Why is the “ideal” iterator \>3x slower t…

---

## [How to implement efficient custom array](https://discourse.julialang.org/t/how-to-implement-efficient-custom-array/22189)

<div class="topic-metadata">

**Author:** [@stemann](https://discourse.julialang.org/u/stemann)\
**Replies:** 4\
**Last updated:** [March 23, 2019, 7:41am UTC](https://discourse.julialang.org/t/how-to-implement-efficient-custom-array/22189 "2019-03-23T07:41:27Z")

</div>

How to implement a custom StridedArray or DenseArray? I have some C-code which returns a pointer to an array, which I can wrap using unsafe\_wrap. I need to build a custom array-implementation, but operations on this cus…

---

## [Compiling error](https://discourse.julialang.org/t/compiling-error/21793)

<div class="topic-metadata">

**Author:** [@thomas\_vilches](https://discourse.julialang.org/u/thomas_vilches)\
**Replies:** 2\
**Last updated:** [March 21, 2019, 6:50pm UTC](https://discourse.julialang.org/t/compiling-error/21793 "2019-03-21T18:50:51Z")

</div>

Hey everyone, I am not sure if this is the right way to ask something, but here I am: I am getting an error when I trying to compile some packages, for instance “using DataFrames” is returning the message: using DataFr…

---

## [Tensor multiplication](https://discourse.julialang.org/t/tensor-multiplication/21450)

<div class="topic-metadata">

**Author:** [@Michiel](https://discourse.julialang.org/u/Michiel)\
**Replies:** 9\
**Last updated:** [March 20, 2019, 2:47pm UTC](https://discourse.julialang.org/t/tensor-multiplication/21450 "2019-03-20T14:47:34Z")

</div>

Hi all, I am implementing a function to perform a generalization of matrix multiplication to a general N-dimensional array or tensor. This product is denoted as \\times\_m to multiply a conformable matrix A with a tensor \\…

---

## [Allocating column of sparseArrays adds explicit zeros](https://discourse.julialang.org/t/allocating-column-of-sparsearrays-adds-explicit-zeros/22011)

<div class="topic-metadata">

**Author:** [@Adrien](https://discourse.julialang.org/u/Adrien)\
**Replies:** 8\
**Last updated:** [March 19, 2019, 10:53pm UTC](https://discourse.julialang.org/t/allocating-column-of-sparsearrays-adds-explicit-zeros/22011 "2019-03-19T22:53:56Z")

</div>

I’m not sure if this is a bug or a feature but copying a sparse vector into a column of a sparse matrix keeps (or rather adds) some of the zeros explicitly: julia\> using SparseArrays julia\> m=sparse(\[\[0,1,2,0,0\] \[0,3,…

---

## [Function parameter works faster than type parameter](https://discourse.julialang.org/t/function-parameter-works-faster-than-type-parameter/22018)

<div class="topic-metadata">

**Author:** [@fjarri](https://discourse.julialang.org/u/fjarri)\
**Replies:** 2\
**Last updated:** [March 19, 2019, 12:39pm UTC](https://discourse.julialang.org/t/function-parameter-works-faster-than-type-parameter/22018 "2019-03-19T12:39:52Z")

</div>

Consider the following code: using Random using BenchmarkTools @inline function testfunc1(x::UInt64, y::UInt64, p::UInt64, ::Val{P}) where P x \* y \* p end @inline function testfunc2(x::UInt64, y::UInt64, p::UInt6…

---

## [Assistance in avoiding allocations in summations](https://discourse.julialang.org/t/assistance-in-avoiding-allocations-in-summations/21998)

<div class="topic-metadata">

**Author:** [@MrRobot](https://discourse.julialang.org/u/MrRobot)\
**Replies:** 8\
**Last updated:** [March 18, 2019, 5:35pm UTC](https://discourse.julialang.org/t/assistance-in-avoiding-allocations-in-summations/21998 "2019-03-18T17:35:14Z")

</div>

I need to do several summations of specific matrix column(s). I can’t figure out a way to get rid of temporary allocations. The code below is my best version, but it leaves a lot to be desired. If I don’t use @view, tim…

---

## [Reusing buffer arrays by providing them as arguments to functions](https://discourse.julialang.org/t/reusing-buffer-arrays-by-providing-them-as-arguments-to-functions/21942)

<div class="topic-metadata">

**Author:** [@jonas-schulze](https://discourse.julialang.org/u/jonas-schulze)\
**Replies:** 5\
**Last updated:** [March 17, 2019, 9:43am UTC](https://discourse.julialang.org/t/reusing-buffer-arrays-by-providing-them-as-arguments-to-functions/21942 "2019-03-17T09:43:06Z")

</div>

I have a function that needs a Vector{Int} for buffering, which I would like to reuse when I call that function over and over again in a loop. My idea was to create that vector outside and clearing it before every use. I…

---

## [Most performant way to get 0-d array pointing to a variable](https://discourse.julialang.org/t/most-performant-way-to-get-0-d-array-pointing-to-a-variable/21947)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 2\
**Last updated:** [March 16, 2019, 8:50pm UTC](https://discourse.julialang.org/t/most-performant-way-to-get-0-d-array-pointing-to-a-variable/21947 "2019-03-16T20:50:46Z")

</div>

First this my be a little ill formatted as I am typing it on my phone at a muffler shop. I am Trying to figure out what the most performance way of generating a 0-dim array of a variable to use as passing by ref. Now f…

---

## [Fast Dict value modification by accessing Dict.vals](https://discourse.julialang.org/t/fast-dict-value-modification-by-accessing-dict-vals/21277)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 16\
**Last updated:** [March 14, 2019, 5:43pm UTC](https://discourse.julialang.org/t/fast-dict-value-modification-by-accessing-dict-vals/21277 "2019-03-14T17:43:34Z")

</div>

I have a use case that needs to blindly change the values stored in a Dict without worrying about the keys and do so quickly. The solution is effective: function dict\_value\_shift!(d::Dict{Ti,Tv},shift::Tv) where Ti whe…

---

## [StaticRanges](https://discourse.julialang.org/t/staticranges/20919)

<div class="topic-metadata">

**Author:** [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Replies:** 6\
**Last updated:** [March 14, 2019, 12:40am UTC](https://discourse.julialang.org/t/staticranges/20919 "2019-03-14T00:40:20Z")

</div>

I’m working on what may turn into a package. https://github.com/Tokazama/StaticRanges.jl Conceptually it’s fairly simple. It has a one type StaticRange and a convenient interface through srange (which is meant to act l…

---

## [Wrong results in calculation](https://discourse.julialang.org/t/wrong-results-in-calculation/21567)

<div class="topic-metadata">

**Author:** [@ancu](https://discourse.julialang.org/u/ancu)\
**Replies:** 21\
**Last updated:** [March 12, 2019, 8:21pm UTC](https://discourse.julialang.org/t/wrong-results-in-calculation/21567 "2019-03-12T20:21:12Z")

</div>

I’m a newbie for Julia. I just test the simple code as follows: for i in range(10,30) println(“10^$i=”,10^i) end but I get the results: 10^10=10000000000 10^11=100000000000 10^12=1000000000000 10^13=1000000000000…

---

## [Convert symbolic SymPy expression to native Julia code?](https://discourse.julialang.org/t/convert-symbolic-sympy-expression-to-native-julia-code/21757)

<div class="topic-metadata">

**Author:** [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Replies:** 2\
**Last updated:** [March 12, 2019, 8:13am UTC](https://discourse.julialang.org/t/convert-symbolic-sympy-expression-to-native-julia-code/21757 "2019-03-12T08:13:50Z")

</div>

I believe it is possible and might be done already but I have not found. It would gain an infinite factor in the evaluation speed as in the example below:

---

## [Confusing benchmark time results and memory allocation depending on number of calls for function with zip](https://discourse.julialang.org/t/confusing-benchmark-time-results-and-memory-allocation-depending-on-number-of-calls-for-function-with-zip/21627)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 12\
**Last updated:** [March 12, 2019, 12:37am UTC](https://discourse.julialang.org/t/confusing-benchmark-time-results-and-memory-allocation-depending-on-number-of-calls-for-function-with-zip/21627 "2019-03-12T00:37:40Z")

</div>

Hello, I recently discovered a very strange behavior which I cannot understand and I would like to ask you for help on this. I have simplified the original code as much as possible to reproduce this behavior. Consider t…

---

## [Double for loop using filtered ranges](https://discourse.julialang.org/t/double-for-loop-using-filtered-ranges/21722)

<div class="topic-metadata">

**Author:** [@MrRobot](https://discourse.julialang.org/u/MrRobot)\
**Replies:** 5\
**Last updated:** [March 11, 2019, 9:31am UTC](https://discourse.julialang.org/t/double-for-loop-using-filtered-ranges/21722 "2019-03-11T09:31:21Z")

</div>

I have some MWE below. What I want is to have a subsection of a range, interact with the rest of the range, but not itself. Also, I posted this on stackoverflow … I should have put it here first I think… For instance i…

---

## [Fast type indexing](https://discourse.julialang.org/t/fast-type-indexing/21702)

<div class="topic-metadata">

**Author:** [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Replies:** 6\
**Last updated:** [March 10, 2019, 11:11pm UTC](https://discourse.julialang.org/t/fast-type-indexing/21702 "2019-03-10T23:11:40Z")

</div>

tldr: I’m trying to find the most performant method for indexing Tuple.parameters in a struct similar to SArray{S\<:Tuple} where I want f(::SArray{S}, i::Int) where S = S.parameters\[i\]. All my current solutions require a …

---

## [Iterate over hdf5 names()](https://discourse.julialang.org/t/iterate-over-hdf5-names/21706)

<div class="topic-metadata">

**Author:** [@davidavdav](https://discourse.julialang.org/u/davidavdav)\
**Replies:** 1\
**Last updated:** [March 10, 2019, 4:38pm UTC](https://discourse.julialang.org/t/iterate-over-hdf5-names/21706 "2019-03-10T16:38:49Z")

</div>

Hello, I’ve got a large, flat HDF5 file, and I’d like to iterate over the objects with a name matching r".\*-y". It seems I can iterate objects over fd = HFD5.h5open(filename) using for obj in fd ## use obj end but…

---

## [Pandas to DataFrame conversion with nested arrays takes very long](https://discourse.julialang.org/t/pandas-to-dataframe-conversion-with-nested-arrays-takes-very-long/21671)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 0\
**Last updated:** [March 9, 2019, 11:35am UTC](https://discourse.julialang.org/t/pandas-to-dataframe-conversion-with-nested-arrays-takes-very-long/21671 "2019-03-09T11:35:14Z")

</div>

I wanted to work on the analysis of experimental data that I gathered with a python program. The data is saved in a pickled Pandas dataframe. Each row is a trial and there are about 20,000 of those. There are about 40 co…

---

## [Julia silently stop working while computing the rank of some not that big matrix](https://discourse.julialang.org/t/julia-silently-stop-working-while-computing-the-rank-of-some-not-that-big-matrix/21463)

<div class="topic-metadata">

**Author:** [@Adrien](https://discourse.julialang.org/u/Adrien)\
**Replies:** 9\
**Last updated:** [March 9, 2019, 10:29am UTC](https://discourse.julialang.org/t/julia-silently-stop-working-while-computing-the-rank-of-some-not-that-big-matrix/21463 "2019-03-09T10:29:23Z")

</div>

I wrote a custom function computing the rank of some matrices (I need an exact computation, and the entries are mod p integers for some small prime p which is why I’m not using the built-in rank function). This is nothin…

---

## [Unbounded IterativeSolvers.Gmres! different output to MATLAB, slows convergence significantly](https://discourse.julialang.org/t/unbounded-iterativesolvers-gmres-different-output-to-matlab-slows-convergence-significantly/21499)

<div class="topic-metadata">

**Author:** [@timmm](https://discourse.julialang.org/u/timmm)\
**Replies:** 13\
**Last updated:** [March 7, 2019, 9:06am UTC](https://discourse.julialang.org/t/unbounded-iterativesolvers-gmres-different-output-to-matlab-slows-convergence-significantly/21499 "2019-03-07T09:06:55Z")

</div>

Hi all, For project here: GitHub - Timmmdavis/FischerNewton: Julia version of NUM4LCP.m I am having issues with the results of IterativeSolvers.Gmres! The main code is under: FischerNewton/src/fischer\_newton.jl If I ad…

---

## [CuArrays and garbage collection when doing FFT convolutions](https://discourse.julialang.org/t/cuarrays-and-garbage-collection-when-doing-fft-convolutions/12412)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 12\
**Last updated:** [March 6, 2019, 8:39pm UTC](https://discourse.julialang.org/t/cuarrays-and-garbage-collection-when-doing-fft-convolutions/12412 "2019-03-06T20:39:01Z")

</div>

Hi, I am using CuArrays to perform fft convolutions and I am getting the error ERROR: CUFFTError(code 2, cuFFT failed to allocate GPU or CPU memory). I have threads about collecting temporaries but I don’t know how to…

---

## [Large Matrix Takes Forever](https://discourse.julialang.org/t/large-matrix-takes-forever/21328)

<div class="topic-metadata">

**Author:** [@olabaz](https://discourse.julialang.org/u/olabaz)\
**Replies:** 4\
**Last updated:** [March 4, 2019, 5:06pm UTC](https://discourse.julialang.org/t/large-matrix-takes-forever/21328 "2019-03-04T17:06:01Z")

</div>

Hi, I am new to Julia and I am writing a program that makes a random matrix drawn from the Haar distribution. It works fine for small matrices ~200x200 but when I try for 1000x1000 the program takes a very long time to r…

---

## [Fastest way to index matrices](https://discourse.julialang.org/t/fastest-way-to-index-matrices/21429)

<div class="topic-metadata">

**Author:** [@Donald\_Williams](https://discourse.julialang.org/u/Donald_Williams)\
**Replies:** 6\
**Last updated:** [March 3, 2019, 8:49pm UTC](https://discourse.julialang.org/t/fastest-way-to-index-matrices/21429 "2019-03-03T20:49:19Z")

</div>

I am wondering best practices for indexing matrices in Julia. The following seems less than ideal, but struggling to find a good way to do, e.g., cor\_mat\[ - j, -j\], as most examples are cor\_mat\[ j , j \] online. Note tha…

---

## [Memory layout of structs with mutable fields](https://discourse.julialang.org/t/memory-layout-of-structs-with-mutable-fields/21400)

<div class="topic-metadata">

**Author:** [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Replies:** 42\
**Last updated:** [March 3, 2019, 7:41pm UTC](https://discourse.julialang.org/t/memory-layout-of-structs-with-mutable-fields/21400 "2019-03-03T19:41:17Z")

</div>

Hello, I had a question about memory layout of structs that contain mutable fields. e.g. struct Test{Float64} id :: Int data::Vector{Float64} end testarr = \[Test(1, \[2.1,\]), Test(2, \[3.1,\])\] pointer(testarr, 2)…

---

## [How to benchmark distributed function calls?](https://discourse.julialang.org/t/how-to-benchmark-distributed-function-calls/21319)

<div class="topic-metadata">

**Author:** [@biona001](https://discourse.julialang.org/u/biona001)\
**Replies:** 1\
**Last updated:** [March 2, 2019, 10:42am UTC](https://discourse.julialang.org/t/how-to-benchmark-distributed-function-calls/21319 "2019-03-02T10:42:27Z")

</div>

Hello Julia community, I used pmap for some cross validation routine. Upon benchmarking on 4 cores, I noticed ~4 times speedup compared to single core. Then I wanted to know how much overhead is associated with running …

---

## [Dot(x, inv.(y)) vs non-allocating one, the former is faster?](https://discourse.julialang.org/t/dot-x-inv-y-vs-non-allocating-one-the-former-is-faster/21338)

<div class="topic-metadata">

**Author:** [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Replies:** 5\
**Last updated:** [March 2, 2019, 12:01am UTC](https://discourse.julialang.org/t/dot-x-inv-y-vs-non-allocating-one-the-former-is-faster/21338 "2019-03-02T00:01:19Z")

</div>

In looking at some recent updates in Distributions I saw code like this dot(w, inv.(x)) and thought that better could be done to avoid allocating inv.(x) however what I came up with was always slower and I’m not sure why…

---

## [Allocations in Comprehensions](https://discourse.julialang.org/t/allocations-in-comprehensions/21309)

<div class="topic-metadata">

**Author:** [@kwild](https://discourse.julialang.org/u/kwild)\
**Replies:** 2\
**Last updated:** [March 1, 2019, 10:55pm UTC](https://discourse.julialang.org/t/allocations-in-comprehensions/21309 "2019-03-01T22:55:37Z")

</div>

Hi, I wonder if there is a simple way to construct a container (Array or Tuple) with comprehensions or similar but with the performance of a hand-written container: julia\> @time \[fill(1, 1000), fill(1, 1000), fill(1, 1…

---

## [Insert values in multiple tables SQLite in a single for loop](https://discourse.julialang.org/t/insert-values-in-multiple-tables-sqlite-in-a-single-for-loop/21357)

<div class="topic-metadata">

**Author:** [@Santiago\_Cuervo](https://discourse.julialang.org/u/Santiago_Cuervo)\
**Replies:** 2\
**Last updated:** [March 1, 2019, 6:54pm UTC](https://discourse.julialang.org/t/insert-values-in-multiple-tables-sqlite-in-a-single-for-loop/21357 "2019-03-01T18:54:02Z")

</div>

Is there a way to insert all those values in a SQLite data base in a single loop? I’ve wrote as much loops as tables I have with the same structure. How do I call variables in a loop?. Thank you blocks=readlines(“block…

---

## [Why Julia and linear algebra module are incredibly slow, compare to C++ and Eigen](https://discourse.julialang.org/t/why-julia-and-linear-algebra-module-are-incredibly-slow-compare-to-c-and-eigen/21304)

<div class="topic-metadata">

**Author:** [@Amin\_Abouee](https://discourse.julialang.org/u/Amin_Abouee)\
**Replies:** 14\
**Last updated:** [March 1, 2019, 3:37pm UTC](https://discourse.julialang.org/t/why-julia-and-linear-algebra-module-are-incredibly-slow-compare-to-c-and-eigen/21304 "2019-03-01T15:37:29Z")

</div>

Hi, I developed a julia file to compare its performance with C++. I implemented the homography estimation based on DLT algortihm. In brief, I created a 8\*9 matrix A from two bundle of four 3D points and solve Ah=0. So…

[Previous page](https://discourse.julialang.org/c/usage/perf/37.md?page=130)

[Next page](https://discourse.julialang.org/c/usage/perf/37.md?page=132)
