• 2 Posts
  • 403 Comments
Joined 2 years ago
cake
Cake day: July 30th, 2023

help-circle


  • TLDR: 3.11 is twice as fast as 3.10 at doing global name lookups, so an old speedup hack of aliasing a global function locally isn’t needed.

    For example, when calling len() in a loop, going l=len, and calling l() in the loop was faster in 3.10. In 3.11, moreso in 3.13, it’s almost a wash.

    However, the author says this:

    Accessing functions through a module [e.g. math.sin()] or a deep attribute chain can still carry overhead. Creating a local alias or using “from module import name” continues to be effective in those situations.

    But when I look at the numbers, I would say 3.13 is pretty close to making it an unnecessary optimization in general. A little subjective on how you interpret the numbers.

    Great info, but this was like trying to use a recipe and reading the author’s life story to get there.


















  • We follow normal rounding rules in Canada. 1, 2 round down to 0. 3, 4 round up to 5. 6, 7 round down to 5. 8, 9 round up to 10.

    Can you game the system? Yes!

    As a business, make sure all your prices (plus tax) come to a price ending in 3, 4, 8, or 9. When consumers buy a single item you’ll get the rounding up (edit: if they pay cash) and make sweet, sweet profit. But if they buy more than one item, you’re SOL on controlling the rounding.

    As a consumer, you have way more control. First, pay with cash whenever the price will round down and you can probably “profit” 5 or so dollars a year. (Assuming you pay with cash on or two times a day, saving 1 to 2 cents each time.) Pay with credit or debit each time the price will would round up.

    Second, you can get real fancy. You can learn tax rules in depth so you know what items will or won’t be taxed and at what rate (we have federal and provincial taxes but they don’t apply to everything and they don’t follow the same rules on what is taxed.) But, you can use this info to always know what the final bill will be and always buy combinations of items that end in 2 or 7 (or 1 and 6 if you’re lazy) and always pay cash. You can profit like $20 a year or something doing this.

    In reality? No one gives a shit until that one rare time you’re paying with cash and it rounds down. It’s your lucky day and you do the Six Flags Man dance. It’s like finding a penny and picking it up.