News for hackers. Stuff that matters.
Re:Rust for Python Programmers by asQuirreL on Wednesday May 27, 2015 @05:17AM (#9610178)
Nice writeup! One thing though, I believe Rust's BTreeMap [1] is a B-Tree (not a binary tree, as suggested), i.e. it's a tree whose branch factor is generally greater than 2.

The docs say that if you don't give a branch factor, a sensible choice is made for you, probably to get nodes to fit neatly into cache lines, so seeing as we are storing 35 unsigned 64 bit integers, this would be around 16 or 32 elements in a single node, and a depth of about 2. This means that, because the current implementation of BTreeMap does linear searches at insertion, for this particular use case, the BTreeMap isn't doing much better than a plain old array, that you are insertion sorting.

TL;DR: Storing the results in a vector and then in-placing sorting it could be faster, but not noticeably. I know this isn't the point of the article, but it was just an observation I had :)

[1]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.ht...

Re:Rust for Python Programmers by dbaupp on Wednesday May 27, 2015 @06:31AM (#9610422)
> sensible choice is made for you

At the moment, it's chosen to be 6: https://doc.rust-lang.org/src/collections/btree/map.rs.html#... (note the FIXME though).

Re:Rust for Python Programmers by the_mitsuhiko on Wednesday May 27, 2015 @07:57AM (#9610697)
Fixed. I primarily picked the btree because it made the example nice and short :)