• 1 Post
  • 33 Comments
Joined 1 year ago
cake
Cake day: September 1st, 2023

help-circle







  • I would argue that having distinct match and search helps readability. The difference between match('((([0-9]+-[0-9]+)|([0-9]+))[,]?)+[^,]', s) and search('((([0-9]+-[0-9]+)|([0-9]+))[,]?)+[^,]', s) is clear without the need for me to parse the regular expression myself. It also helps code reuse. Consider that you have PHONE_NUMBER_REGEX defined somewhere. If you only had a method to “search” but not to “match”, you would have to do something like search(f"\A{PHONE_NUMBER_REGEX}\Z", s), which is error-prone and less readable. Most likely you would end up having at least two sets of precompiled regex objects (i.e. PHONE_NUMBER_REGEX and PHONE_NUMBER_FULLMATCH_REGEX). It is also a fairly common practice in other languages’ regex libraries (cf. [1,2]). Golang, which is usually very reserved in the number of ways to express the same thing, has 16 different matching methods[3].

    Regarding re.findall, I see what you mean, however I don’t agree with your conclusions. I think it is a useful convenience method that improves readability in many cases. I’ve found these usages from my code, and I’m quite happy that this method was available[4]:

    digits = [digit_map[digit] for digit in re.findall("(?=(one|two|three|four|five|six|seven|eight|nine|[0-9]))", line)]
    [(minutes, seconds)] = re.findall(r"You have (?:(\d+)m )?(\d+)s left to wait", text)
    

    [1] https://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html

    [2] https://en.cppreference.com/w/cpp/regex

    [3] https://pkg.go.dev/regexp

    [4] https://github.com/search?q=repo%3Ahades%2Faoc23 findall&type=code








  • I’m not necessarily disagreeing with you, but that estimate could have been wrong by a factor of 10 easily. The idea of an “average video” being 50MB, for example, is questionable: at typical bitrates of 1080p videos this would amount to about a minute-long video. I don’t think that’s an average video at all. It also doesn’t account for many things, for example the cost of replicating new videos to the CDN.

    I also don’t find the idea of YouTube not being profitable ridiculous or hilarious. YouTube definitely wasn’t profitable before monetisation, and Google used to run it for prestige and data collection purposes at a financial loss. They clearly have been trying to make it more profitable, but whether or not they have crossed the break-even point in the past or are still hoping to cross it in the future is not as clear to me as it is to you.


  • He did some short format writing, but The Martian was his first published novel, I think. He was a software engineer before that.

    Artemis follows the same pattern of a capable main protagonist solving problems, so it is not very different from the other books in terms of characters, but it is much better in character depth and development than The Martian.


  • Just as a general advice that has only occurred to me recently: if you don’t like a book, stop reading it and read another one. There are great books, and there are mediocre, and also you some might work better for you, and some worse. If you start with a book that you don’t like, and power through it anyway, you might be reluctant to try another one.

    You’ve mentioned sci-fi, but didn’t mention Robert Sheckley. If you haven’t read any of his stories, drop everything and read Citizen in Space, for example.

    If you’d rather go for something more modern, fun, but also a little sad, try The Curious Incident of the Dog in the Night-Time by Mark Haddon.

    For something extremely entertaining, but also mysterious, try Everyone in My Family Has Killed Someone by Benjamin Stevenson.

    If you’re into videogames and like drama, try Tomorrow, and Tomorrow, and Tomorrow by Gabrielle Zevin. That’s the best book I’ve read in the past 5 years.