willmcgugan,
@willmcgugan@mastodon.social avatar

challenge for y'all.

Your mission, should you chose to accept it...

Write a function to get the last 5 lines from a text file as efficiently as possible. Assume line endings are all "\n".

Should work with text files of any size.

tmr232,
@tmr232@mastodon.social avatar

@willmcgugan what's your measurement of efficiency?
Single thread runtime? Total runtime? Least bytes read from disk?

willmcgugan,
@willmcgugan@mastodon.social avatar

@tmr232 Walk clock time.

tmr232,
@tmr232@mastodon.social avatar

@willmcgugan So (expectedly) it seems that running through bytes with regex is way faster than Python code.
Now to check file read times...

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