Add arrays of arrays definition more simple #4167
Unanswered
hupo376787
asked this question in
Language Ideas
Replies: 6 comments 8 replies
This comment has been hidden.
This comment has been hidden.
-
This is C# limitation. .NET runtime does supports allocating jagged arrays in one shot. |
Beta Was this translation helpful? Give feedback.
5 replies
-
If you're in this situation, why wouldn't you use a 2D array? I.e.: double[,] x = new double[5, 3]; |
Beta Was this translation helpful? Give feedback.
0 replies
-
Because they're inefficient in comparison to a 1D array of 1D arrays.
…On Sun, 22 Nov 2020 at 14:01, Petr Onderka ***@***.***> wrote:
If you're in this situation, why wouldn't you use a 2D array? I.e.:
double[,] x = new double[5, 3];
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4167 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADIEDQL6C7I47GWZAAOZK33SREKVPANCNFSM4T6PX7FA>
.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
I've seen some recent benchmarks run, and I'm fairly sure they were running
Core 3.1 - the SD arrays were a good 50% quicker.
…On Sun, 22 Nov 2020 at 14:32, HaloFour ***@***.***> wrote:
My understanding is that this is no longer true with .NET Core (and was
never true with Mono). Multidimensional arrays _should_be faster but .NET
Framework had a fairly inefficient method of bounds checking.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4167 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADIEDQKS5GMYEQE3J44GUPDSREOIJANCNFSM4T6PX7FA>
.
|
Beta Was this translation helpful? Give feedback.
2 replies
-
I've just had it confirmed - it was on 3.1, but he's going to run it again
against NET5 when he gets the chance.
…On Sun, 22 Nov 2020 at 14:43, HaloFour ***@***.***> wrote:
Looks like there are still JIT workitems out there to improve their
performance: dotnet/runtime#35293
<dotnet/runtime#35293>
I'd be curious to see different benchmarks against .NET 5 (or Mono, since
I've read a few reports that this performance difference doesn't exist on
that runtime). Either way it seems like an implementation detail that can
be fixed by the runtime and not an intrinsic behavior of multidimensional
arrays. Bounds checking aside you'd think that they'd have better
performance due to memory locality, since the individual array elements in
a jagged array could be anywhere.
My only (minor) concern with syntax like var foo = new T[x][y]; is that
it hides the fact that there are *x* separate allocations going on.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4167 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADIEDQKLRMNSDU4AIQR3HRLSREPSDANCNFSM4T6PX7FA>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background and Motivation
Many other languages can use
double[][] x = new double[5][3];
But donet can only do like this:
Proposed API
Add
double[][] x = new double[5][3];
Beta Was this translation helpful? Give feedback.
All reactions