# dot syntax in pyjulia

**URL:** <https://discourse.julialang.org/t/dot-syntax-in-pyjulia/11974>\
**Category:** Performance\
**Created:** [June 26, 2018, 5:45pm UTC](https://discourse.julialang.org/t/dot-syntax-in-pyjulia/11974 "2018-06-26T17:45:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![atombear](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/atombear/32/8488_2.png) [@atombear](https://discourse.julialang.org/u/atombear)\
**Post date:** [June 26, 2018, 5:45pm UTC](https://discourse.julialang.org/t/dot-syntax-in-pyjulia/11974/1 "2018-06-26T17:45:41Z")

</div>

Hello, I have a question about using dot syntax in python. In trying to write a broadcast-able function in julia that I can call from python, i have found it convenient to do the following:

```julia
export func

function func(x::Float64, y::Float64)
    <body>
end

func(x::Union{Float64, Array{Float64}}, y::Union{Float64, Array{Float64}})=func.(x, y)

```

I may be going off the rails here, but otherwise I’m not sure how to make broadcasting available on the python-side. Any thoughts would be much appreciated.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 26, 2018, 5:50pm UTC](https://discourse.julialang.org/t/dot-syntax-in-pyjulia/11974/2 "2018-06-26T17:50:24Z")

</div>

I would just do:

```julia
export func

function scalarfunc(x, y)
    <body>
end

func(x, y) = scalarfunc.(x, y)

```

Broadcasting works just fine on scalars and adds no overhead, so the “broadcasted” function can be completely separate from the scalar kernel.

---

<div class="post-metadata">

**Author:** ![atombear](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/atombear/32/8488_2.png) [@atombear](https://discourse.julialang.org/u/atombear)\
**Post date:** [June 26, 2018, 5:59pm UTC](https://discourse.julialang.org/t/dot-syntax-in-pyjulia/11974/3 "2018-06-26T17:59:31Z")

</div>

so, do i lose anything by not specifying type in the function signature? that’s what worried me about this.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 26, 2018, 6:44pm UTC](https://discourse.julialang.org/t/dot-syntax-in-pyjulia/11974/4 "2018-06-26T18:44:21Z")

</div>

Nope! Method signatures are really only required if you specifically want to depend upon the internal structure of an argument or a particular behavior — so you can dispatch to it over a different (often more general) implementation. The performance of methods written as `f(x::Float64) = ...` vs. `f(x::Number) = ...` vs. `f(x) = ...` will be identical.

---

<div class="post-metadata">

**Author:** ![atombear](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/atombear/32/8488_2.png) [@atombear](https://discourse.julialang.org/u/atombear)\
**Post date:** [June 26, 2018, 6:45pm UTC](https://discourse.julialang.org/t/dot-syntax-in-pyjulia/11974/5 "2018-06-26T18:45:39Z")

</div>

thank you!
