# Is 'SVector' a keyword in julia?

**URL:** <https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 8, 2023, 12:08am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306 "2023-12-08T00:08:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Post date:** [December 8, 2023, 12:08am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/1 "2023-12-08T00:08:43Z")

</div>

In a package, I see a lot of ‘SVector’. It looks like a datatype. But I cannot find it by help.

```julia
help?> SVector
search: DenseVector SparseVector AbstractVector StridedVector AbstractSparseVector DenseVecOrMat

Couldn't find SVector
Perhaps you meant Vector, BitVector or Schur
  No documentation found.

  Binding SVector does not exist.

```

I cannot find the definition of SVector in the package neither.

---

<div class="post-metadata">

**Author:** ![adienes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adienes/32/37459_2.png) [@adienes](https://discourse.julialang.org/u/adienes)\
**Post date:** [December 8, 2023, 12:10am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/2 "2023-12-08T00:10:09Z")

</div>

this type is defined in `StaticArrays.jl`

it is not standard library but it may as well be, this type is very very popular to use.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [December 8, 2023, 12:20am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/3 "2023-12-08T00:20:31Z")

</div>

It’s here in the docs, the section of the manual all should read:  
[https://docs.julialang.org/en/v1/manual/performance-tips/](https://docs.julialang.org/en/v1/manual/performance-tips/)

> By using the SVector type from StaticArrays.jl,

It’s been discussed to add it to Julia, as a type (not keyword), well that package, but it’s not strictly needed.

It’s understandable that the help doesn’t explain it but I think it should be considered to add it there as a hint, and some other info too.

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [December 8, 2023, 1:35am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/4 "2023-12-08T01:35:57Z")

</div>

JuliaHub’s package-ecosystem-wide docs search works pretty well - StaticArrays.SVector is the [first search result](https://juliahub.com/ui/Search?q=SVector&type=docs). There’s also a symbol definition search I hadn’t noticed before, but it also unearthed the correct result as the [first hit](https://juliahub.com/ui/Search?q=SVector&type=symbols&u=define).

---

<div class="post-metadata">

**Author:** ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Post date:** [December 8, 2023, 2:19am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/5 "2023-12-08T02:19:32Z")

</div>

it is very popular now?

I do not see its big advantage actually. As the docs say, it is only faster than the standard ‘Array’ for matrices smaller than 10\*10 in size.

I do know why that is worth the efforts.

---

<div class="post-metadata">

**Author:** ![adienes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adienes/32/37459_2.png) [@adienes](https://discourse.julialang.org/u/adienes)\
**Post date:** [December 8, 2023, 2:30am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/6 "2023-12-08T02:30:16Z")

</div>

> [@jiang\_ming\_zhang](#):
>
> it is only faster than the standard ‘Array’ for matrices smaller than 10\*10 in size.

that is a common size!

it’s very possible this is not a useful type for your use case, but there many use cases for which it is

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [December 8, 2023, 9:33am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/7 "2023-12-08T09:33:34Z")

</div>

> [@jiang\_ming\_zhang](#):
>
> I do not see its big advantage actually. As the docs say, it is only faster than the standard ‘Array’ for matrices smaller than 10\*10 in size.
> 
> I do know why that is worth the efforts.

There are several scenarios where one needs to work with arrays of a known (often small) length, e.g. when working with spatial coordinates (say in three dimensions). In this case, the vectors may be of length 3, and linear operators may be 3x3 matrices (e.g. coordinate rotation matrices). These are common use cases where static arrays are used.

If this is not your use case, then you don’t need (and probably shouldn’t use) static arrays.

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [December 8, 2023, 10:04am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/8 "2023-12-08T10:04:52Z")

</div>

> [@jiang\_ming\_zhang](#):
>
> I cannot find the definition of SVector in the package neither.

Probably the package has this line:

```
using StaticArrays

```

which imported symbols like `SVector` into your namespace. If readability is more valued than convenience, it could have been

```
import StaticArrays

```

in which case `SVector` should always be written as `StaticArrays.SVector`, so someone reading the code will not be left wondering. Another possibility is writing

```
using StaticArrays: SVector

```

in which case `SVector` can be used directly, but a reader can easily find the definition of `SVector` in the `using` statement.

Personally, I try to use the latter two versions whenever I write a package, and I only use the simple `using` statement for quickly trying things in the REPL or Jupyter notebooks.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [December 8, 2023, 11:23am UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/9 "2023-12-08T11:23:24Z")

</div>

This post was temporarily hidden by the community for possibly being off-topic, unfocused, inappropriate, or spammy.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 8, 2023, 1:15pm UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/10 "2023-12-08T13:15:42Z")

</div>

In my simulations I get a 10 times speed-up… Many small vectors…

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [December 8, 2023, 11:48pm UTC](https://discourse.julialang.org/t/is-svector-a-keyword-in-julia/107306/11 "2023-12-08T23:48:31Z")

</div>

> [@jiang\_ming\_zhang](#):
>
> I do not see its big advantage actually. As the docs say, it is only faster than the standard ‘Array’ for matrices smaller than 10\*10 in size.

My most common matrix sizes are 3x3 and 4x4. So, yeah, it’s actually amazingly useful.
