timClicks,
@timClicks@mastodon.nz avatar

An short comparison between Python and Rust for text processing tasks. (An efficient algorithm is left as an exercise for the reader. 😅 ) https://youtu.be/3-odyhxzWkE

TomSwirly,
@TomSwirly@toot.community avatar

@timClicks

from string import ascii_uppercase as upper, ascii_lowercase as lower

SWAP_CASE = str.maketrans(upper + lower, lower + upper)
assert 'No Gods, No Masters'.translate(SWAP_CASE) == 'nO gODS, nO mASTERS'

(Tested for correctness...)

timClicks,
@timClicks@mastodon.nz avatar

@TomSwirly That only swaps characters in the ASCII range, but I like it.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • cubers
  • everett
  • rosin
  • Youngstown
  • ngwrru68w68
  • slotface
  • osvaldo12
  • Durango
  • kavyap
  • InstantRegret
  • tacticalgear
  • khanakhh
  • megavids
  • GTA5RPClips
  • normalnudes
  • thenastyranch
  • mdbf
  • ethstaker
  • modclub
  • Leos
  • tester
  • provamag3
  • cisconetworking
  • anitta
  • JUstTest
  • lostlight
  • All magazines