Re: My AoC program in D is just as fast as in Python

2025-11-26 Thread Andy Valencia via Digitalmars-d-learn
On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: I implemented [Advent of Code 2015, Day 6, Part 1](https://adventofcode.com/2015/day/6) in D. The code is here: https://github.com/jabbalaci/AdventOfCode2015/tree/main/day06/d/part1 . It runs for 3 seconds. I found it a bit much, so

Re: My AoC program in D is just as fast as in Python

2025-11-26 Thread Paul Backus via Digitalmars-d-learn
On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: Another question: for `process_line()`, I pass the dictioary by reference, since I want to modify the dictionary inside this procedure. Without `ref`, the original `d` in `main()` remained empty. However, I've already written progra

Re: My AoC program in D is just as fast as in Python

2025-11-25 Thread MrJay via Digitalmars-d-learn
On Tuesday, 25 November 2025 at 22:31:30 UTC, MrJay wrote: On Tuesday, 25 November 2025 at 22:19:19 UTC, MrJay wrote: when you are comparing two languages you have to be careful to not accidentally add accidental bottlenecks, where you are not comparing the bottle neck rather than the languages

Re: My AoC program in D is just as fast as in Python

2025-11-25 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 25 November 2025 at 22:31:30 UTC, MrJay wrote: On Tuesday, 25 November 2025 at 22:19:19 UTC, MrJay wrote: [...] really didnt like how I explained this to restate it profiling is quite difficult, and must be done with care because its very easy to profile a bottleneck rather than

Re: My AoC program in D is just as fast as in Python

2025-11-25 Thread MrJay via Digitalmars-d-learn
On Tuesday, 25 November 2025 at 22:19:19 UTC, MrJay wrote: when you are comparing two languages you have to be careful to not accidentally add accidental bottlenecks, where you are not comparing the bottle neck rather than the languages really didnt like how I explained this to restate it pro

Re: My AoC program in D is just as fast as in Python

2025-11-25 Thread MrJay via Digitalmars-d-learn
On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: I implemented [Advent of Code 2015, Day 6, Part 1](https://adventofcode.com/2015/day/6) in D. The code is here: https://github.com/jabbalaci/AdventOfCode2015/tree/main/day06/d/part1 . It runs for 3 seconds. I found it a bit much, so

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread monkyyy via Digitalmars-d-learn
On Monday, 24 November 2025 at 16:48:49 UTC, Jabba Laci wrote: On Monday, 24 November 2025 at 16:16:07 UTC, monkyyy wrote: On Monday, 24 November 2025 at 15:46:30 UTC, Kapendev wrote: On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: #!/usr/bin/env rdmd Compile it with `dub build

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: I implemented [Advent of Code 2015, Day 6, Part 1](https://adventofcode.com/2015/day/6) in D. The code is here: https://github.com/jabbalaci/AdventOfCode2015/tree/main/day06/d/part1 . It runs for 3 seconds. I found it a bit much, so

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread Jabba Laci via Digitalmars-d-learn
On Monday, 24 November 2025 at 16:16:07 UTC, monkyyy wrote: On Monday, 24 November 2025 at 15:46:30 UTC, Kapendev wrote: On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: #!/usr/bin/env rdmd Compile it with `dub build --compiler=ldc2 --build=release`: "we taught him wrong as a

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread Kapendev via Digitalmars-d-learn
On Monday, 24 November 2025 at 16:16:07 UTC, monkyyy wrote: On Monday, 24 November 2025 at 15:46:30 UTC, Kapendev wrote: On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: #!/usr/bin/env rdmd Compile it with `dub build --compiler=ldc2 --build=release`: "we taught him wrong as a

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread monkyyy via Digitalmars-d-learn
On Monday, 24 November 2025 at 15:46:30 UTC, Kapendev wrote: On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: #!/usr/bin/env rdmd Compile it with `dub build --compiler=ldc2 --build=release`: "we taught him wrong as a joke"; he's already doing the better thing of #!, bad kap >:

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread user1234 via Digitalmars-d-learn
On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: I implemented [Advent of Code 2015, Day 6, Part 1](https://adventofcode.com/2015/day/6) in D. The code is here: https://github.com/jabbalaci/AdventOfCode2015/tree/main/day06/d/part1 . It runs for 3 seconds. I found it a bit much, so

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread monkyyy via Digitalmars-d-learn
On Monday, 24 November 2025 at 15:27:33 UTC, Jabba Laci wrote: On Monday, 24 November 2025 at 15:07:19 UTC, Serg Gini wrote: Do you use LDC with -O3? With this setting, it's 2 seconds instead of 3. Still very slow. In this case a matrix would have been a better choice (I'll rewrite with that

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread Kapendev via Digitalmars-d-learn
On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: I implemented [Advent of Code 2015, Day 6, Part 1](https://adventofcode.com/2015/day/6) in D. The code is here: https://github.com/jabbalaci/AdventOfCode2015/tree/main/day06/d/part1 . It runs for 3 seconds. I found it a bit much, so

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread Jabba Laci via Digitalmars-d-learn
On Monday, 24 November 2025 at 15:07:19 UTC, Serg Gini wrote: Do you use LDC with -O3? With this setting, it's 2 seconds instead of 3. Still very slow. In this case a matrix would have been a better choice (I'll rewrite with that), but I find it strange that the dictionary solution is so slo

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread monkyyy via Digitalmars-d-learn
On Monday, 24 November 2025 at 15:07:19 UTC, Serg Gini wrote: On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: Maybe its hashing is too slow? How could it be sped up? Do you use LDC with -O3? look at the types, that isnt going to matter

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread Serg Gini via Digitalmars-d-learn
On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: Maybe its hashing is too slow? How could it be sped up? Do you use LDC with -O3?

Re: My AoC program in D is just as fast as in Python

2025-11-24 Thread monkyyy via Digitalmars-d-learn
On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote: To my surprise, the Python program also ran for 3 seconds. I expected that the D program should be much faster. What's the rule here? `int[Pair]` aa's are fundmental and useful; but they are a cache miss in every language Becau