flub,
@flub@mastodon.social avatar

It's curious how in making things readable often results in writing for loops nicely. While in you make the same kind of code readable by making good use of iterator combinators and removing the loops.

berkes,
@berkes@mastodon.nl avatar

@flub because in python, iterators have a horrible design.

I'm convinced it's mostly caused by how blocks are defined in whitespace. (This is also a practical reason why whitespace as block definitions, sucks).
And partially because in python, lambdas, procs and closures are an afterthought, retrofitted , poorly (probably due to the whitespace thing).

And lastly, because in python scoping is a hot mess (slightly better than Ruby's or JS's, but still bad).

berkes,
@berkes@mastodon.nl avatar

@flub what I find most frustrating, though, is how very different the performance of iterators vs loops can be.

In , refactoring from one to another might have some small effect. But in , I need to know the intricacies of both, when refactoring. Last week I refactored a python iterators into a loop, no functional change, and a run went from 13 seconds to over 4 minutes! Apparently smth with memory allocations and -copies. As leaky an abstraction I have ever seen.

ilmai,
@ilmai@hachyderm.io avatar

@berkes @flub actually my experience is that in Rust, using iterators is often faster than using loops, since it gives the compiler more power and information

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