Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sharing some ideas about Fluent Python

Sharing some ideas about Fluent Python

Cheesecake Labs

March 22, 2018
Tweet

More Decks by Cheesecake Labs

Other Decks in Programming

Transcript

  1. Agenda • About Fluent Python and its author • The

    Python Data Model • Data Structures - Most common • Generators and Comprehensions • Iterators
  2. The Python Data Model • They are not meant to

    be called by you; • Your objects can behave like the built-in types; • They allow your objects to interact with basic language constructs, such as: * Iteration, collections, attribute access, operator overloading, function and method invocation, object creation and destruction, string representation and formatting, managed contexts…
  3. Generators and Comprehensions • A more readable (but not always),

    concise and effective way to build data structures; • More performatic; • Genexp saves memory because it yields items one by one using the iterator protocol;
  4. Iterators • Every generator is an iterator (but not vice

    versa); • An iterator retrieves item from a collection, while a generator can produce items "out of thin air"; • Python uses generators in many places (e.g. range())