Have you ever started on some creative work, and given yourself an arbitrary restriction within which to do it? Like making some pixel art, but you will only use black or white pixels. I think it’s quite a fun way to drive the creative and problem solving juices, to test the limits of the restriction and learn new techniques.
In the two most recent posts we focused on the Python object system. We learned what Python objects and Python types are, how they are defined and what determines their behavior. This discussion gave us a good understanding of how Python objects work in general. What we haven’t discussed is how particular objects, such as strings, integers and lists, are implemented. In this and several upcoming posts we’ll cover the implementations of the most important and most interesting built-in types. The subject of today’s post is
Python is my favourite programming language. Since I discovered it in 2004, programming in Python became my favourite hobby. I’ve tried to learn a few other languages and have never found one as friendly to beginners as Python. As readers of this blog know, these days I am particularly interested in tracebacks, and I am likely paying more attention than most to Python’s improvements in this area: Python is becoming more and more precise in the information that it provides to the users when something goes wrong…
People bash OO a lot these days, I’m increasingly coming to the opinion they’re right, at least in Python. My point here is not to argue that OO is bad per se, more that its introduction is simply unnecessary, AKA not useful.
Let’s see how we can create QR codes that look however we want, while preserving links. We’ll also show the world’s first working QR gif (as far as I know).
On November 29, version 1.7 of SymPy, a Python library for symbolic mathematics, was released. The new version brings a large number of enhancements and bug fixes, and some minor backward incompatibilities. While these are enumerated in detail in the release notes, we will take advantage of this opportunity to look at some of the things that can be done with SymPy and explore its interface options through several detailed examples.
Mypy is an optional static type checker for Python. It’s been around since 2012 and is gaining traction even since. One of the main benefits of using a type checker is getting errors at “compile time” rather than at run time.
Exhaustiveness checking is a common feature of type checkers, and a very useful one! In this article I’m going to show you how you can get mypy to perform exhaustiveness checking!
defaultdictis an incredibly useful tool to specify default values for missing keys (RealPython has a great primer on them).
I found I was taking up so much memory to store the value 0 for an algorithm which counted rather infrequent elements in a huge sequence split into many chunks. Using a
defaultdict(int)for each distinct element to store which indices had a non-zero count of the respective element greatly optimised it, but I yearned for a
defaultlistequivalent to standardise this approach and generally make my code more expressive.
Flat is a library for creating and manipulating digital forms of fine arts. Its aim is to enable experimentation with and testing of unpredictable or automated processes, to inspect the beginning of the “new”.
It grew out of the needs for generative design, architecture and art. The concept of “design” is more of a subject of study yet to be delved into, hence the fitter term for subtitle is “infrastructure”.
In this demonstration we will use Keras and TensorFlow 2.3 to explore data, normalize data, and build both a linear model and Deep Neural Network (DNN) to solve a regression problem. TensorFlow Core 2.3 includes tf.keras, which provides the high level (high abstraction) Keras Application Programming Interface (API) for TensorFlow. Keras simplifies the command and control of TensorFlow. The TensorFlow ecosystem also contains straightforward and simple vehicles for normalization and other common Machine Learning data preparation constructs.
Some of the new major new features and changes in Python 3.9 are:
PEP 573, Module State Access from C Extension Methods
PEP 584, Union Operators in dict
PEP 585, Type Hinting Generics In Standard Collections
PEP 593, Flexible function and variable annotations
PEP 602, Python adopts a stable annual release cadence
PEP 614, Relaxing Grammar Restrictions On Decorators
PEP 615, Support for the IANA Time Zone Database in the Standard Library
PEP 616, String methods to remove prefixes and suffixes
PEP 617, New PEG parser for CPython
BPO 38379, garbage collection does not block on resurrected objects;
BPO 38692, os.pidfd_open added that allows process management without races and signals;
BPO 39926, Unicode support updated to version 13.0.0;
BPO 1635741, when Python is initialized multiple times in the same process, it does not leak memory anymore;
A number of Python builtins (range, tuple, set, frozenset, list, dict) are now sped up using PEP 590 vectorcall;
A number of Python modules (_abc, audioop, _bz2, _codecs, _contextvars, _crypt, _functools, _json, _locale, operator, resource, time, _weakref) now use multiphase initialization as defined by PEP 489;
A number of standard library modules (audioop, ast, grp, _hashlib, pwd, _posixsubprocess, random, select, struct, termios, zlib) are now using the stable ABI defined by PEP 384.