Fluent Python, Second Edition on Fluent Python, the lizard book https://fluentpython.com/ Recent content in Fluent Python, Second Edition on Fluent Python, the lizard book Hugo -- gohugo.io en-us Sat, 19 Jun 2021 00:00:00 +0000 Managing Ordered Sequences with Bisect https://fluentpython.com/extra/ordered-sequences-with-bisect/ Thu, 17 Jun 2021 20:01:08 -0300 https://fluentpython.com/extra/ordered-sequences-with-bisect/ The bisect module offers two main functions that use the binary search algorithm to quickly find and insert items in any sorted sequence. Searching with bisect Inserting with insort Searching with bisect bisect(haystack, needle) does a binary search for needle in haystack—which must be a sorted sequence—to locate the position where needle can be inserted while maintaining haystack in ascending order. In other words, all items appearing up to that position are less than or equal to needle. Internals of sets and dicts https://fluentpython.com/extra/internals-of-sets-and-dicts/ Thu, 24 Jun 2021 19:19:18 -0300 https://fluentpython.com/extra/internals-of-sets-and-dicts/ Python’s dict and set are built on top of hash tables. This post explains how the use of hash tables results in the strengths and limitations of those container types. Here are some questions this article answers: How efficient are Python dict and set? Why are set elements unordered? Why can’t we use any Python object as a dict key or set element? Building Multi-Character Emojis https://fluentpython.com/extra/multi-character-emojis/ Sat, 03 Jul 2021 18:57:00 -0300 https://fluentpython.com/extra/multi-character-emojis/ Unicode has always supported building accented characters by combining letters and diacritics. This idea has been extended to meet the growing demand for emojis. Figure 1. Modern families. This post explains how to combine special markers and characters to make new pictographs. Contents: Country Flags Skin Tones Rainbow Flag and ZWJ Combinations Modern Families Further Reading Parsing binary records with struct https://fluentpython.com/extra/parsing-binary-struct/ Mon, 05 Jul 2021 21:27:18 -0300 https://fluentpython.com/extra/parsing-binary-struct/ The struct module provides functions to parse fields of bytes into a tuple of Python objects, and to perform the opposite conversion, from a tuple into packed bytes. struct can be used with bytes, bytearray, and memoryview objects. The struct module is powerful and convenient, but before using it you should seriously consider alternatives, so that’s the first short section in this post. Contents: Should we use struct? Weak References https://fluentpython.com/extra/weak-references/ Tue, 06 Jul 2021 21:16:42 -0300 https://fluentpython.com/extra/weak-references/ Introduction The presence of references is what keeps an object alive in memory. When the reference count of an object reaches zero, the garbage collector disposes of it. But sometimes it is useful to have a reference to an object that does not keep it around longer than necessary. A common use case is a cache. Weak references to an object do not increase its reference count. The object that is the target of a reference is called the referent. Introspection of Function Parameters https://fluentpython.com/extra/function-introspection/ Sun, 18 Jul 2021 19:51:00 -0300 https://fluentpython.com/extra/function-introspection/ Contents: Introduction to Function Introspection Retrieving Information About Parameters Soapbox: About Bobo Introduction to Function Introspection Python functions are full-fledged objects. As such, they have attributes like __doc__: >>> def factorial(n): ... """returns n!""" ... return 1 if n < 2 else n * factorial(n - 1) ... >>> factorial.__doc__ 'returns n!' Invoking help(factorial) on the Python console shows the function signature and the __doc__ text. Classic Coroutines https://fluentpython.com/extra/classic-coroutines/ Wed, 11 Aug 2021 22:50:00 -0300 https://fluentpython.com/extra/classic-coroutines/ Contents: Coroutine Flavors Story of this Post How Coroutines Evolved from Generators Basic Behavior of a Generator Used as a Coroutine Example: Coroutine to Compute a Running Average Decorators for Coroutine Priming Coroutine Termination and Exception Handling Returning a Value from a Coroutine Using yield from The Meaning of yield from Python Lingo https://fluentpython.com/lingo/ Wed, 28 Jul 2021 12:59:00 -0300 https://fluentpython.com/lingo/ Many terms here are not exclusive to Python, but some common terms have definitions that are specific to the Python community. Also see the official Python Glossary. Contents: A B C D E F G H I K L M N O P R S T U V W Y Z ABC (programming language) A programming language created by Leo Geurts, Lambert Meertens, and Steven Pemberton. About fluentpython.com https://fluentpython.com/about/ Sat, 19 Jun 2021 00:00:00 +0000 https://fluentpython.com/about/ FluentPython.com complements Fluent Python, Second Edition with extra content. Unless otherwise noted, the content of this site was written by me, Luciano Ramalho, the author of Fluent Python. The content and source code for this site is in the public repository fluentpython/book-site on Github. Code for the examples in the book is in another repository: fluentpython/example-code-2e. Luciano Ramalho—June 19, 2021 Work in Progress This is a static site made with Hugo and Asciidoctor.