• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Python Generators - Talk at PySthlm meetup #15
 

Python Generators - Talk at PySthlm meetup #15

on

  • 469 views

Describing how you can use python generator functions to process a file without loading it all in memory before starting

Describing how you can use python generator functions to process a file without loading it all in memory before starting

Statistics

Views

Total Views
469
Views on SlideShare
466
Embed Views
3

Actions

Likes
0
Downloads
4
Comments
0

2 Embeds 3

https://twitter.com 2
http://www.linkedin.com 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Python Generators - Talk at PySthlm meetup #15 Python Generators - Talk at PySthlm meetup #15 Presentation Transcript

    • Python Generators PySthlm Meetup #15 – Python Best Practices – Oct 31, 2013 Samuel Lampa twitter.com/smllmp
    • The “normal” (bad) way
    • The “normal” (bad) way New temporary data structures created and kept in memory == BAD!!!
    • Using Generator function
    • Using Generator function A yield (“return”) for every iteration, so it can be used immediately without temp data structure == GOOD!
    • Using Generator function A yield (“return”) for every iteration, so it can be used immediately without temp data structure == GOOD! So, this is the generator function
    • Using Generator function A yield (“return”) for every iteration, so it can be used immediately without temp data structure == GOOD! So, this is the generator function … which can be iterated over, like this ...
    • Using list-comprehension syntax
    • Using list-comprehension syntax Here, the generator function Is defined in one row
    • Chaining generator functions
    • Chaining generator functions
    • Creds and more info: ● David Beazleys Python Generator intro: →dabeaz.com/generators David Beazley on twitter: @dabeaz
    • Thank you! Samuel Lampa G+: gplus.to/saml twitter: @smllmp Blog: saml.rilspace.org Developer @ www.uppmax.uu.se www.farmbio.uu.se www.rilpartner.se