~/talk

"Fifty shades of `sign`"

Talkat PyCascades 2022 · 2022-02-05..02-06· [python]
slides:none on file

Compares more than a dozen implementations of a sign(n) function that returns -1, 0, or 1, and demonstrates concrete alternatives: using absolute-value division (abs(x)/x) avoided for float/divide concerns, using boolean-to-int indexing (list indexed by truthy sums) that covers all cases without special-casing zero, and using Python 3.10 match statement for pattern matching. Shows compiled bytecode equivalence between simple if/elif and conditional-expression versions, profiles all implementations, and finds the straightforward if/elif is fastest and simplest in practice.

AI-written summary · about

  1. 0:00Introduction
  2. 1:39About me
  3. 2:45Twitter
  4. 3:05Short story
  5. 4:07Sine function
  6. 4:50Testing my function
  7. 5:30Why my code looks like a beginner
  8. 6:33Conditional expressions
  9. 8:08Objects as booleans
  10. 8:47Double conditional expression
  11. 11:54Absolute value function
  12. 12:58Division
  13. 16:54Redundancy
  14. 18:10Conditional Expression
  15. 21:39Two Conditions
  16. 26:21Python
  17. 27:00Timing
  18. 27:25Timing table
  19. 28:08Last function
  20. 28:49David Wesley
  21. 29:28References
  22. 29:44Written version
  23. 30:05Newsletter
  24. 30:18Feedback
  25. 30:45Puppies
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.