# How to include a Distributed into a package?

**URL:** <https://discourse.julialang.org/t/how-to-include-a-distributed-into-a-package/81561>\
**Category:** General Usage\
**Created:** [May 24, 2022, 9:16am UTC](https://discourse.julialang.org/t/how-to-include-a-distributed-into-a-package/81561 "2022-05-24T09:16:17Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![dmetivie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmetivie/32/6926_2.png) [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Post date:** [September 13, 2024, 1:52pm UTC](https://discourse.julialang.org/t/how-to-include-a-distributed-into-a-package/81561/3 "2024-09-13T13:52:51Z")

</div>

To anyone interested and maybe related to some [other questions](https://discourse.julialang.org/t/should-you-use-spawnat-everywhere-within-a-package-distributed-jl/112134), what works for me is to add

```julia
module MyPkg
using Distributed
f(x) = ...
function big(...)
  ....
  return pmap(f, iterator)
end

export big
end

```

Then outside the pkg I just need to do

```julia
using Distributed
addprocs(10)
using MyPkg
@everywhere using MyPkg
big(...) # works and is faster!

```

It is very simple to modify existing code to make it distributed that way.  
If I don’t want distributed, I just do not load `using Distributed` and `pmap` performs as a regular `map`.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-include-a-distributed-into-a-package/81561)._
