# General Usage

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

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

**Page:** 587

---

## [Overloading Base.hash is 2x slower than an identical function](https://discourse.julialang.org/t/overloading-base-hash-is-2x-slower-than-an-identical-function/63058)

<div class="topic-metadata">

**Author:** [@odow](https://discourse.julialang.org/u/odow)\
**Replies:** 1\
**Last updated:** [June 17, 2021, 1:20am UTC](https://discourse.julialang.org/t/overloading-base-hash-is-2x-slower-than-an-identical-function/63058 "2021-06-17T01:20:55Z")

</div>

Can anyone explain (or reproduce) the following? Why is the Base.hash version slower and why the allocation? julia\> using BenchmarkTools julia\> mutable struct Foo end julia\> struct Bar f::Foo x:…

---

## [Spawn task on thread after delay and fetch result later](https://discourse.julialang.org/t/spawn-task-on-thread-after-delay-and-fetch-result-later/63051)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 0\
**Last updated:** [June 16, 2021, 9:57pm UTC](https://discourse.julialang.org/t/spawn-task-on-thread-after-delay-and-fetch-result-later/63051 "2021-06-16T21:57:32Z")

</div>

I am trying to execute a function on a different thread after a specified delay. I could use Timer, but I need to fetch the result. As shown below, my solution was to use sleep. I was wondering if this is there are bette…

---

## [Suggestion violates cauality](https://discourse.julialang.org/t/suggestion-violates-cauality/62958)

<div class="topic-metadata">

**Author:** [@Mark\_Nahabedian](https://discourse.julialang.org/u/Mark_Nahabedian)\
**Replies:** 4\
**Last updated:** [June 16, 2021, 6:30pm UTC](https://discourse.julialang.org/t/suggestion-violates-cauality/62958 "2021-06-16T18:30:49Z")

</div>

Anyone seen this before: ERROR: LoadError: ArgumentError: Package Pkg not found in current path: - Run \`import Pkg; Pkg.add("Pkg")\` to install the Pkg package. Any ideas what I might have done to cause it? I’m using a…

---

## [Is it possible to have the last iterator change the fastest in Iterator.product?](https://discourse.julialang.org/t/is-it-possible-to-have-the-last-iterator-change-the-fastest-in-iterator-product/63039)

<div class="topic-metadata">

**Author:** [@curious](https://discourse.julialang.org/u/curious)\
**Replies:** 4\
**Last updated:** [June 16, 2021, 6:11pm UTC](https://discourse.julialang.org/t/is-it-possible-to-have-the-last-iterator-change-the-fastest-in-iterator-product/63039 "2021-06-16T18:11:13Z")

</div>

In Julia’s Iterators.product, the first iterator changes the fastest. Is there an easy way to get elements in an order, so that the last iterator changes the fastest? For example with three sequences, I obtain: res = It…

---

## [Speed of internal function](https://discourse.julialang.org/t/speed-of-internal-function/62914)

<div class="topic-metadata">

**Author:** [@Daniel\_Scheinerman](https://discourse.julialang.org/u/Daniel_Scheinerman)\
**Replies:** 7\
**Last updated:** [June 16, 2021, 6:09pm UTC](https://discourse.julialang.org/t/speed-of-internal-function/62914 "2021-06-16T18:09:30Z")

</div>

I stumbled upon some strange timings today. I’m posting a somewhat minimal below. Essentially it seems that if you write a function that returns a function what you return along with it dramatically effects the speed of …

---

## [Is there a package with a function that gives cartesian product of two or more sequences?](https://discourse.julialang.org/t/is-there-a-package-with-a-function-that-gives-cartesian-product-of-two-or-more-sequences/63030)

<div class="topic-metadata">

**Author:** [@curious](https://discourse.julialang.org/u/curious)\
**Replies:** 2\
**Last updated:** [June 16, 2021, 4:31pm UTC](https://discourse.julialang.org/t/is-there-a-package-with-a-function-that-gives-cartesian-product-of-two-or-more-sequences/63030 "2021-06-16T16:31:33Z")

</div>

Package IterTools used to have a product function to create a cartesian product of two or more sequences. Version 1.3.0 of IterTools still has this function, but it appears to be deprecated. Asking for help in the repl r…

---

## [Segfault with ccall when the code is loaded as package](https://discourse.julialang.org/t/segfault-with-ccall-when-the-code-is-loaded-as-package/63017)

<div class="topic-metadata">

**Author:** [@barucden](https://discourse.julialang.org/u/barucden)\
**Replies:** 4\
**Last updated:** [June 16, 2021, 3:51pm UTC](https://discourse.julialang.org/t/segfault-with-ccall-when-the-code-is-loaded-as-package/63017 "2021-06-16T15:51:09Z")

</div>

Hi, I found some strange behavior which I am not sure is intended. Maybe I am missing something totally obvious, in which case I apologize. I found the following MWE. First, create a new package ~$ julia (@v1.6) pkg\> g…

---

## [How does the memory model of pyjulia work?](https://discourse.julialang.org/t/how-does-the-memory-model-of-pyjulia-work/62989)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 3\
**Last updated:** [June 16, 2021, 12:42pm UTC](https://discourse.julialang.org/t/how-does-the-memory-model-of-pyjulia-work/62989 "2021-06-16T12:42:24Z")

</div>

I am using Julia from Python via pyjulia which has a how it works. But I want to understand if there are performance implications. E.g. if I have a numpy array in python and use it in Julia; is Julia making a copy or us…

---

## [Cannot convert an object of type DataFrame to an object of type Array](https://discourse.julialang.org/t/cannot-convert-an-object-of-type-dataframe-to-an-object-of-type-array/61598)

<div class="topic-metadata">

**Author:** [@valperez](https://discourse.julialang.org/u/valperez)\
**Replies:** 2\
**Last updated:** [June 16, 2021, 12:33pm UTC](https://discourse.julialang.org/t/cannot-convert-an-object-of-type-dataframe-to-an-object-of-type-array/61598 "2021-06-16T12:33:08Z")

</div>

Hi, I have a Data Frame that I want to convert into an Array but Julia gives me the following error: MethodError: Cannot convert an object of type DataFrame to an object of type Array I believe that there has someth…

---

## [Lorenz attractor has changed?](https://discourse.julialang.org/t/lorenz-attractor-has-changed/62986)

<div class="topic-metadata">

**Author:** [@Minimum-Pollution-96](https://discourse.julialang.org/u/Minimum-Pollution-96)\
**Replies:** 1\
**Last updated:** [June 16, 2021, 10:04am UTC](https://discourse.julialang.org/t/lorenz-attractor-has-changed/62986 "2021-06-16T10:04:17Z")

</div>

I feel like the lorenz attractor that’s being plotted on the Julia Plots site has changed. I think it used to look similar to the one in Julialang site. Ignore this if this is just a figment of my imagination. If not, wh…

---

## [PartitionBy, retaining key](https://discourse.julialang.org/t/partitionby-retaining-key/62820)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 4\
**Last updated:** [June 16, 2021, 6:28am UTC](https://discourse.julialang.org/t/partitionby-retaining-key/62820 "2021-06-16T06:28:17Z")

</div>

Is there something like Python’s itertools.groupby, which is like Julia’s Transducers.PartitionBy but yields (partition\_key, partition\_entries) pairs instead of only partition entries? cc @tkf

---

## [Does julia have a construct analogous to Racket's parameters?](https://discourse.julialang.org/t/does-julia-have-a-construct-analogous-to-rackets-parameters/62658)

<div class="topic-metadata">

**Author:** [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Replies:** 11\
**Last updated:** [June 16, 2021, 5:51am UTC](https://discourse.julialang.org/t/does-julia-have-a-construct-analogous-to-rackets-parameters/62658 "2021-06-16T05:51:29Z")

</div>

Racket has this cool thing where you can define implicit values called parameters: 4.13 Dynamic Binding: parameterize. Is there anything analogous in julia? For example, it would be convenient in the implementation of t…

---

## [How to create a function that uses an object attribute if it exists](https://discourse.julialang.org/t/how-to-create-a-function-that-uses-an-object-attribute-if-it-exists/62972)

<div class="topic-metadata">

**Author:** [@lpratafe](https://discourse.julialang.org/u/lpratafe)\
**Replies:** 3\
**Last updated:** [June 16, 2021, 2:55am UTC](https://discourse.julialang.org/t/how-to-create-a-function-that-uses-an-object-attribute-if-it-exists/62972 "2021-06-16T02:55:31Z")

</div>

Hey everyone, I believe what I am trying to do is pretty simple, but I couldn’t figure it out by myself, and what I read from the documentation wasn’t very helpful. Also, I did search in the forum but couldn’t find exact…

---

## [How to get the current world age inside a generated function?](https://discourse.julialang.org/t/how-to-get-the-current-world-age-inside-a-generated-function/62969)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 5\
**Last updated:** [June 15, 2021, 10:57pm UTC](https://discourse.julialang.org/t/how-to-get-the-current-world-age-inside-a-generated-function/62969 "2021-06-15T22:57:37Z")

</div>

A generated function I’m writing needs to determine if its allowed to call a function its been passed, or if that would result in a world-age error (in which case it would fall back to something else). As part of this, I…

---

## [Array step index](https://discourse.julialang.org/t/array-step-index/62920)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 8\
**Last updated:** [June 15, 2021, 9:59pm UTC](https://discourse.julialang.org/t/array-step-index/62920 "2021-06-15T21:59:18Z")

</div>

There are arrays whose first index isn’t 1. If I want the next value after the first index, is it always x\[begin+1\], or is there a generalization like x\[begin+step\]?

---

## [The fastest way to calculate matrix inversion](https://discourse.julialang.org/t/the-fastest-way-to-calculate-matrix-inversion/62892)

<div class="topic-metadata">

**Author:** [@yingqiuz](https://discourse.julialang.org/u/yingqiuz)\
**Replies:** 9\
**Last updated:** [June 15, 2021, 12:14am UTC](https://discourse.julialang.org/t/the-fastest-way-to-calculate-matrix-inversion/62892 "2021-06-15T00:14:32Z")

</div>

Hi all I need to calculate the inverse of a positive definite matrix H of the form H = (X’ \* X + Diagonal(d)). X is a flat matrix, having (dominantly) more columns than rows. d consists of positive, large values. The m…

---

## [Writing this inner constructor with a macro](https://discourse.julialang.org/t/writing-this-inner-constructor-with-a-macro/62945)

<div class="topic-metadata">

**Author:** [@Amval](https://discourse.julialang.org/u/Amval)\
**Replies:** 2\
**Last updated:** [June 15, 2021, 2:16pm UTC](https://discourse.julialang.org/t/writing-this-inner-constructor-with-a-macro/62945 "2021-06-15T14:16:36Z")

</div>

Hello, I am trying to write a macro to reduce some boilerplate. I have some builder method for structs to do some complicated transformations on a dict. I am copypasting something similar to this over and over: struct …

---

## [Customizing SharedArray](https://discourse.julialang.org/t/customizing-sharedarray/62933)

<div class="topic-metadata">

**Author:** [@FredericN](https://discourse.julialang.org/u/FredericN)\
**Replies:** 4\
**Last updated:** [June 15, 2021, 1:44pm UTC](https://discourse.julialang.org/t/customizing-sharedarray/62933 "2021-06-15T13:44:07Z")

</div>

When creating a SharedArray as in using SharedArrays using Distributed addprocs(4) a = SharedArray{Float64}(40) the partitioning of entries is made automatically. Does anyone knows if it is possible to set my own pa…

---

## [ContourPlot3D (surface) in Julia](https://discourse.julialang.org/t/contourplot3d-surface-in-julia/62923)

<div class="topic-metadata">

**Author:** [@maoc](https://discourse.julialang.org/u/maoc)\
**Replies:** 2\
**Last updated:** [June 15, 2021, 12:52pm UTC](https://discourse.julialang.org/t/contourplot3d-surface-in-julia/62923 "2021-06-15T12:52:28Z")

</div>

I am trying to plot the 3D surface given by the zero of a function. I have a complicated function given by function mcl(Y,w) BLAH BLAH end Where Y is a 2-element Array{Int64,1} and w is a real number. For example mcl(…

---

## [Using VSCode and Julia Plugin, User Input Doesn't Seem To Work](https://discourse.julialang.org/t/using-vscode-and-julia-plugin-user-input-doesnt-seem-to-work/62919)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 2\
**Last updated:** [June 15, 2021, 12:09pm UTC](https://discourse.julialang.org/t/using-vscode-and-julia-plugin-user-input-doesnt-seem-to-work/62919 "2021-06-15T12:09:47Z")

</div>

I’m unable to properly accept user input from the terminal in VS Code. I have a file called asking-for-user-input.jl, that has the following code: function main() println("Enter your first name:") first\_name = rea…

---

## [JuliaInXL package future](https://discourse.julialang.org/t/juliainxl-package-future/62941)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 0\
**Last updated:** [June 15, 2021, 10:42am UTC](https://discourse.julialang.org/t/juliainxl-package-future/62941 "2021-06-15T10:42:24Z")

</div>

I notice JuliaInXL has changed from paid to a standard JuliaPro package. Since (I believe) VS Code is the preferred editor going forward which isn’t supported by JuliaPro, would it be possible to make JuliaInXL just a s…

---

## [Distributed matrix](https://discourse.julialang.org/t/distributed-matrix/62225)

<div class="topic-metadata">

**Author:** [@FredericN](https://discourse.julialang.org/u/FredericN)\
**Replies:** 2\
**Last updated:** [June 15, 2021, 9:26am UTC](https://discourse.julialang.org/t/distributed-matrix/62225 "2021-06-15T09:26:03Z")

</div>

Dear All, I would like some advice. Which package (if any) implements distributed (in the MPI fashion) matrices and is compatible with other Krylov solvers. Thanks

---

## [Indexing a document using Dictionary](https://discourse.julialang.org/t/indexing-a-document-using-dictionary/62724)

<div class="topic-metadata">

**Author:** [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Replies:** 10\
**Last updated:** [June 15, 2021, 8:54am UTC](https://discourse.julialang.org/t/indexing-a-document-using-dictionary/62724 "2021-06-15T08:54:22Z")

</div>

Dear All, I would like to ask, if there is a Dict that would be suitable for indexing a large collection of documents. Specifically imagine that each document is composed by a set of words doc1 = \[1,2,3,4,5,\] doc2 = \[3…

---

## [Substitute an equation](https://discourse.julialang.org/t/substitute-an-equation/62913)

<div class="topic-metadata">

**Author:** [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Replies:** 3\
**Last updated:** [June 15, 2021, 7:15am UTC](https://discourse.julialang.org/t/substitute-an-equation/62913 "2021-06-15T07:15:30Z")

</div>

If I have two equations how do I combine them? Do I have to write something like this or is there a shorter way? Maybe something like solve(eq1,eq2,a)? using Symbolics @vars a b c eq1 = ( a = b + c) eq2 = ( b = 3c - a)…

---

## [Problem with Poisson distribution fitting of an array of floats (suffstats is not implemented for (Poisson, Array{Float64,1}))](https://discourse.julialang.org/t/problem-with-poisson-distribution-fitting-of-an-array-of-floats-suffstats-is-not-implemented-for-poisson-array-float64-1/62898)

<div class="topic-metadata">

**Author:** [@AndresCasillas](https://discourse.julialang.org/u/AndresCasillas)\
**Replies:** 3\
**Last updated:** [June 14, 2021, 10:06pm UTC](https://discourse.julialang.org/t/problem-with-poisson-distribution-fitting-of-an-array-of-floats-suffstats-is-not-implemented-for-poisson-array-float64-1/62898 "2021-06-14T22:06:20Z")

</div>

Hi, I’m currently working in Windows 10 with Julia 1.5.3 in a Jupyter notebook, using Distributions. I have an array of type Array{Float64,1} called “derivadas\_reales\_desplazado”. I want to fit a Poisson distribution to…

---

## [How to apply DiffEq for PDEs with a moving boundary?](https://discourse.julialang.org/t/how-to-apply-diffeq-for-pdes-with-a-moving-boundary/61491)

<div class="topic-metadata">

**Author:** [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Replies:** 9\
**Last updated:** [June 14, 2021, 9:52pm UTC](https://discourse.julialang.org/t/how-to-apply-diffeq-for-pdes-with-a-moving-boundary/61491 "2021-06-14T21:52:57Z")

</div>

Suppose we have the following diffusion equation \\frac{\\partial\\phi}{\\partial t} = \\frac{\\partial^2\\phi}{\\partial z^2} with initial condition \\phi(z, t=0) = 0.1 and a boundary condition at z=0 \\frac{\\partial\\phi}…

---

## [See startup options within Julia](https://discourse.julialang.org/t/see-startup-options-within-julia/62901)

<div class="topic-metadata">

**Author:** [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Replies:** 8\
**Last updated:** [June 14, 2021, 8:49pm UTC](https://discourse.julialang.org/t/see-startup-options-within-julia/62901 "2021-06-14T20:49:39Z")

</div>

Is there a way to list the command line options (e.g., -p 10, --optimize=1, etc) used to start Julia from within the REPL?

---

## [Grouping vector of strings by left - right context](https://discourse.julialang.org/t/grouping-vector-of-strings-by-left-right-context/62907)

<div class="topic-metadata">

**Author:** [@djholiver](https://discourse.julialang.org/u/djholiver)\
**Replies:** 0\
**Last updated:** [June 14, 2021, 7:49pm UTC](https://discourse.julialang.org/t/grouping-vector-of-strings-by-left-right-context/62907 "2021-06-14T19:49:09Z")

</div>

Hi, I have seen a few example approaches (covert to DataFrame, write your own), but can’t quite get my scenario to work. I have a vector of strings with a character to split on that maps to the vector of “columns” (sep…

---

## [A question about my drawing](https://discourse.julialang.org/t/a-question-about-my-drawing/62891)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 3\
**Last updated:** [June 14, 2021, 3:59pm UTC](https://discourse.julialang.org/t/a-question-about-my-drawing/62891 "2021-06-14T15:59:26Z")

</div>

How to change the position of legend in the image, it blocks part of the image. thanks!

---

## [Performance comparison of Nvidia A100, V100, RTX2080Ti](https://discourse.julialang.org/t/performance-comparison-of-nvidia-a100-v100-rtx2080ti/62602)

<div class="topic-metadata">

**Author:** [@yixingfu](https://discourse.julialang.org/u/yixingfu)\
**Replies:** 17\
**Last updated:** [June 14, 2021, 12:58pm UTC](https://discourse.julialang.org/t/performance-comparison-of-nvidia-a100-v100-rtx2080ti/62602 "2021-06-14T12:58:47Z")

</div>

When running a bunch of code mostly based on CUDA.jl and consists of mainly (sparse or dense) linear algebra operations, I come to notice that the code runs almost at the same speed for RTX2080Ti and V100, and much faste…

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

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