# Matrix padding

**URL:** <https://discourse.julialang.org/t/matrix-padding/135250>\
**Category:** Internals & Design\
**Tags:** design, matrices\
**Created:** [January 25, 2026, 1:54am UTC](https://discourse.julialang.org/t/matrix-padding/135250 "2026-01-25T01:54:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 25, 2026, 1:54am UTC](https://discourse.julialang.org/t/matrix-padding/135250/1 "2026-01-25T01:54:58Z")

</div>

ok, I started opening things up to look at doing [Pretty-printing small n-d arrays](http://discourse.julialang.org/t/135200), but I came across a interesting choice which I wanted to make sure wasn’t a deliberate design decision. the left and right padding are completely independent, so arrays of type `Any` look like they have twice as many cols as they really do:

```julia-auto
julia> [1039201 "string"; "tst" 8888; 10 'a'; "row4" 5]
2×2 Matrix{Any}:
 1039201 "string"
        "tst" 8888
      10 'a'
        "row4" 5

```

. is there any specific reason it shouldn’t be:

```julia-auto
julia> [1039201 "string"; "tst" 8888; 10 'a'; "row4" 5]
2×2 Matrix{Any}:
 1039201 "string"
 "tst" 8888
      10 'a'
 "row4" 5

```

?

edit: ok, guess I figured out why it’s not like above:

```julia-auto
julia> ["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 0, 0, 0]
4-element Vector{Any}:
  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
 0
 0
 0

```

, but couldn’t it still be something like:

```julia-auto
julia> [1039201 "string"; "tst" 8888; 10 'a'; "row4" 5]
2×2 Matrix{Any}:
 1039201 "string"
 "tst" 8888
      10 'a'
 "row4" 5

```

?

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 25, 2026, 6:36am UTC](https://discourse.julialang.org/t/matrix-padding/135250/2 "2026-01-25T06:36:25Z")

</div>

I’m going to assume it’s fine to fix this, because there are other little annoyances I’ve found with padding too.

matrices don’t take string elision into account:

```julia-auto
julia> ["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 0 0 0 0;0 0 0 0 0]
2×5 Matrix{Any}:
  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ⋯ 23 bytes ⋯ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 0 0 0 0
 0 0 0 0 0

```

and when it thinks it should be shortening the matrix because of this it doesn’t actually remove any columns of the matrix:

```julia-auto
julia> ["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 0 0;0 0 0]
2×3 Matrix{Any}:
  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ⋯ 33 bytes ⋯ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" … 0 0
 0 0  
0

```

edit:

I actually did find something that aligns both directions, complex numbers:

```julia-auto
julia> [1039201 "string"; "test" 8888; 10 'a'; 1+im 1021-4im]
4×2 Matrix{Any}:
 1039201 "string"                                
        "test" 8888
      10 'a'
      1+1im 1021-4im                                     

```

I think I can still overlap the columns if I’m careful about it though

---

<div class="post-metadata">

**Author:** ![yolhan\_mannes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yolhan_mannes/32/220485_2.png) [@yolhan\_mannes](https://discourse.julialang.org/u/yolhan_mannes)\
**Post date:** [January 25, 2026, 7:50pm UTC](https://discourse.julialang.org/t/matrix-padding/135250/3 "2026-01-25T19:50:59Z")

</div>

I like this too, btw, if you keep adding edge cases like that, keep a hackmd proposol updated it will be simpler once you lauch PR.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 25, 2026, 8:30pm UTC](https://discourse.julialang.org/t/matrix-padding/135250/4 "2026-01-25T20:30:22Z")

</div>

eh, this thread wasn’t as interesting to follow. I put in prs to fix the dumbness I was complaining about once I figured out where they came from ([fix elision for matrices with a wide first col by rokke-git · Pull Request #60814 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/60814), [Fix improper alignment of matrices with elided strings by rokke-git · Pull Request #60812 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/60812)), since they were little bugs rather than anything more fundamental.

I do still plan on proposing both changes (nd-array from the last thread, overlapping alignments from this thread), but they’d be separate prs; as they’re each independent, and kinda substantial changes. I’ll have to be rewriting lots of test cases…

---

<div class="post-metadata">

**Author:** ![yolhan\_mannes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yolhan_mannes/32/220485_2.png) [@yolhan\_mannes](https://discourse.julialang.org/u/yolhan_mannes)\
**Post date:** [January 25, 2026, 8:36pm UTC](https://discourse.julialang.org/t/matrix-padding/135250/5 "2026-01-25T20:36:06Z")

</div>

You don’t have to do it all in 1PR, you could make an issue with items and see the response from there, also, not bad to get feedback asap to avoid changing too much in the end, the issue can be general like “proposol for changes on Arrays display”.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [January 26, 2026, 12:33pm UTC](https://discourse.julialang.org/t/matrix-padding/135250/6 "2026-01-26T12:33:26Z")

</div>

that sounds like a great plan; I have now created an issue [here](https://github.com/JuliaLang/julia/issues/60824) to base things off of

---

<div class="post-metadata">

**Author:** ![yolhan\_mannes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yolhan_mannes/32/220485_2.png) [@yolhan\_mannes](https://discourse.julialang.org/u/yolhan_mannes)\
**Post date:** [January 26, 2026, 12:37pm UTC](https://discourse.julialang.org/t/matrix-padding/135250/7 "2026-01-26T12:37:59Z")

</div>

Nice a litle slack message and yre good to go
