News for hackers. Stuff that matters.
Re:Static search trees: 40x faster than binary search by wolfgangK on Tuesday December 31, 2024 @08:15PM (#42563172)
I don't think that Python would be the right language for such low-level performance maxxing endeavor. I would have picked C++ but t was eye opening for me to see how rust enabled such low level optimization, so I'm grateful for the choice.
Re:Static search trees: 40x faster than binary search by curiouscoding on Tuesday December 31, 2024 @08:23PM (#42563202)
Yeah, I don't think python is the right tool here. C++ definitely would be an option though.

Anyway very happy that this is also showing off what rust can do

Re:Static search trees: 40x faster than binary search by ryao on Tuesday December 31, 2024 @10:17PM (#42563688)
As far as I can tell, the community is largely divided into three major groups. Those that can read C, those that can read Python and those that can read both. Using either of them would have dodged criticism that your code examples are not accessible to much of the community.

That said, you are right that Python is not the best language to use when you need to use intrinsics, as you would be writing it in another language and using the Python FFI to access it.

Re:Static search trees: 40x faster than binary search by oguz-ismail on Tuesday December 31, 2024 @10:40PM (#42563800)
> this is also showing off what rust can do

To people who already know Rust, yes. To others, not so much

Re:Static search trees: 40x faster than binary search by ryao on Tuesday December 31, 2024 @08:25PM (#42563219)
C would be useful to the broadest audience. C++ programmers can read C while C programmers cannot always read C++, especially when the newer language constructs are used. I mentioned Python because of its popularity.

Interesting, the Algorithmica article the author cited is in C:

https://en.algorithmica.org/hpc/data-structures/s-tree/

Re:Static search trees: 40x faster than binary search by npalli on Tuesday December 31, 2024 @08:30PM (#42563242)
C++ not C. The author explains his choices elsewhere in the site.
Re:Static search trees: 40x faster than binary search by ryao on Tuesday December 31, 2024 @08:38PM (#42563277)
The code snippets should be accepted by a C compiler and therefore are valid C code.
Re:Static search trees: 40x faster than binary search by npalli on Tuesday December 31, 2024 @08:43PM (#42563302)
If you want to be pedantic, there is a constexpr in the snippets, wont be accepted by the C compiler. More broadly though it is a C++ tutorial. I insisted on it because the author of algorithmica actually explains he chose C++ and perhaps sometime later C/Rust or something might be better. Should respect his POV.
Re:Static search trees: 40x faster than binary search by ryao on Tuesday December 31, 2024 @08:58PM (#42563380)
I had not seen the use of constexpr. You are correct that those are in C++.
Re:Static search trees: 40x faster than binary search by lubutu on Wednesday January 01, 2025 @02:40AM (#42564567)
C23 has constexpr, albeit only for objects, not functions. The code also uses namespaces, as in `std::aligned_alloc(P, T)`.
Re:Static search trees: 40x faster than binary search by ryao on Wednesday January 01, 2025 @05:35AM (#42565197)
You have to be 1/3 down the page to see any of this in the code examples. By that point, you would already have seen a number of examples that are valid C code and it is reasonable to expect the rest to be. At least, that was my experience.