News for hackers. Stuff that matters.
Re:Go performance from version 1.2 to 1.18 by snarkerson on Thursday February 03, 2022 @10:29PM (#30202477)
Version Numbering bothers me.

Mathematically 1.2 is greater than 1.18. Yet in versions it is lesser.

I find this annoying and counter intuitive.

Re:Go performance from version 1.2 to 1.18 by amscanne on Thursday February 03, 2022 @11:47PM (#30202986)
If it helps, a version is simply not a decimal number and the dot is not a decimal point. It’s just a separator. The dot often used for purposes other than a decimal point (a few times in this comment!).
Re:Go performance from version 1.2 to 1.18 by pdpi on Friday February 04, 2022 @01:39AM (#30203557)
Version numbers are effectively base infinity, not base 10. Periods are digit separators, and each digit is written in decimal. The usual representation for IP addresses is basically the same (four base-256 digits separated by periods)
Re:Go performance from version 1.2 to 1.18 by usrusr on Thursday February 03, 2022 @10:50PM (#30202641)
I find it not quite as unintuitive when there are more than two fields: 1.2.0 is almost impossible to be misread as greater than 1.18.0.
Re:Go performance from version 1.2 to 1.18 by twhb on Thursday February 03, 2022 @11:29PM (#30202879)
Interesting how somebody can be tripped up by 1.2 vs 1.18 yet not tripped up by 1/2 vs 1/18. It could just take time, but I think there’s also a factor of feeling that dates are worth learning while version numbers don’t deserve direct attention and instead should be a subset of a nearby concept that does.
Re:Go performance from version 1.2 to 1.18 by sinsterizme on Thursday February 03, 2022 @11:05PM (#30202732)
Yeah I always get tripped up. I feel like we should write it as 1.02, that way it can get up to 1.99 without this issue :)
Re:Go performance from version 1.2 to 1.18 by theshrike79 on Friday February 04, 2022 @05:08AM (#30204897)
You can think of them like 1.2.0 and 1.18.0 if that makes your life easier.

That way your brain can't think of them as numbers any more =)

Re:Go performance from version 1.2 to 1.18 by 1_player on Friday February 04, 2022 @12:53AM (#30203354)
The worst thing is when laymen abbreviate the version number 1.20 to 1.2 - quite confusing.

Versions aren't numbers.

Re:Go performance from version 1.2 to 1.18 by titzer on Thursday February 03, 2022 @10:35PM (#30202535)
Me too.

For Virgil, because I am a fan of the roman poet, I am using roman numerals for the major versions and append a monotonically-increasing-regardless-of-major-version "00XXX" build number to that. This ensures they always sort lexicographically.

...until I get to version IX, i.e. 9, which would sort incorrectly. So I'll just skip 9, 19, 29...90...heh. :)

Re:Go performance from version 1.2 to 1.18 by chrismorgan on Friday February 04, 2022 @12:28AM (#30203233)
If your algorithm is “choose the next number for which its Roman numeral sorts lexicographically higher than the current number”, then if you start at 1 you will only get 35 elements, since 38 (XXXVIII) is the lexicographically-highest Roman numeral.

Using this precise rule, the starting point that gets you furthest is 250, which grants you 153 elements before stopping at 1038 (MXXXVIII).

It’s possible to devise a longer sequence by skipping some numbers (e.g. after 1000 you’d jump to 1100), but I’m too lazy to calculate how you’d do all that.

All this also assumes subtraction rules, which were a late addition to Roman numerals; without subtraction rules, four is written IIII instead of IV, and nine VIIII instead of IX, and so all of 1–49 would be lexicographically sorted.

  from docutils.utils.roman import toRoman

  def sequence(start):
      last = ''
      out = []
      for i in range(start, 5000):
          this = toRoman(i)
          if this > last:
              last = this
              out.append(i)
      return out

  # Brute force way because I’m lazy; takes around ten seconds on my machine.
  start, s = max(((start, sequence(start)) for start in range(1, 5000)), key=lambda x: len(x[1]))
  print(f'{start} gives you {len(s)} items, {s}')
Re:Go performance from version 1.2 to 1.18 by philliphaydon on Thursday February 03, 2022 @11:17PM (#30202809)
OMG I didn't even realise, I was looking at the graphs getting so confused.