Tag: Python

Including data in Python packages

Posted on Thu 02 December 2021 by Austin Bingham

Every time I need to include data in a Python package, I find myself going in circles checking existing projects, blog posts, and every other resource I can find to figure out the right way to do it. For something so seemingly straightforward, including data in a package always turns …

Python virtual environments with pyenv on Apple Silicon

Posted on Tue 20 April 2021 by Ekaterina Nikonova

Apple's recent transition to the new architecture for its Mac computers has caused rather predictable problems for developers whose workflow depends on certain versions of pre-compiled libraries for x86 architecture. While the latest releases of Python come with a universal installer that allows to build universal binaries for M1 systems …

Event-Sourced Domain Models in Python at PyCon UK

Posted on Tue 22 September 2015 by Rob Smallshire

At PyCon UK 2015 I led a very well attended workshop with the goal of introducing Python developers to the tried-and-tested techniques and patterns of Domain Driven Design (DDD), in particular when used as part of an event-sourced architecture.

The two-and-a-half hour workshop was comprised of excerpts from our training …

Event Processing with Transducers

Posted on Fri 27 March 2015 by Rob Smallshire

In the previous article in this series on transducers we looked at lazily evaluating transducers. This time we'll look not at pulling output through a transducer chain from downstream, but at pushing input items into the chain from upstream.

All of the uses of transducers we've demonstrated in Python so …

Lazy Transducer Evaluation

Posted on Tue 20 January 2015 by Rob Smallshire

In the previous article in this series on transducers we looked at transducers which push more items downstream through the reducer chain than they receive from upstream. We promised that this would make lazy evaluation of transducer chains quite interesting.

When used with our transduce() function, our mapping and filtering …

Item Injecting Transducers

Posted on Mon 19 January 2015 by Rob Smallshire

In the previous article in our series on understanding transducers through Python we showed how to support early termination of a reduction operation. This time, we'll demonstrate how transducers can produce more items than they consume. Although this may seem obvious, it leads to some important consequences for implementing lazy …

Terminating Transducers

Posted on Mon 19 January 2015 by Rob Smallshire

In the previous article in this series on transducers, we showed how to implement stateful transducers, and how to deal with any left-over state or other clean-up operations when the reduction operation is complete. Sometimes, however, there is no need to process a whole series of items in order to …

Stateful Transducers

Posted on Mon 19 January 2015 by Rob Smallshire

In the previous article in this series on transducers we saw how we can develop the notion of the transducer from a single function which literally transforms reducers to a more capable protocol which supports two further capabilities: First of all, the association of initial 'seed' values with a reduction …

Enriching the Transducer Protocol

Posted on Mon 19 January 2015 by Rob Smallshire

In the previous article in the series we looked at improving the experience of composing transducers together in Python, by introducing a compose() function. We finished by showing this snippet, which composes a filtering transducer with a mapping transducer to produce a prime-squaring transducer. Recalling that transducers are used to …

Improving Transducer Composition

Posted on Mon 19 January 2015 by Rob Smallshire

In the previous article in this series we derived a Python implementation of transducers from first principles. We finished by showing how transducers can be composed together using regular function call application to give us a single composite reducer which can perform many operations with a single pass of reduce …

Deriving Transducers from First Principles

Posted on Mon 19 January 2015 by Rob Smallshire

What is a transducer?

Transducers - a portmanteau of ‘transform reducers’ - are a new functional programming concept introduced into the Clojure programming language. Although transducers are actually pretty straightforward in retrospect, wrapping your brain around them, especially if you’re not already a competent Clojureist, can be challenging. In this series …

The super() Mystery Resolved

Posted on Wed 20 August 2014 by Austin Bingham

In the previous articles in this series [1] we uncovered a small mystery regarding how Python's super() works, and we looked at some of the underlying mechanics of how super() really works. In this article we'll see how those details work together to resolve the mystery.

The mystery revisited

As …

Method Resolution Order, C3, and Super Proxies

Posted on Thu 31 July 2014 by Austin Bingham

In the previous article in this series we looked at a seemingly simple class graph with some surprising behavior. The central mystery was how a class with two bases can seem to invoke two different method implementations with just a single invocation of super(). In order to understand how that …

Rational Computational Geometry in Python

Posted on Thu 03 July 2014 by Rob Smallshire

In the previous article, we looked at how a standard technique for determining the collinearity of points, based on computing the sign of the area of the triangle formed by two points on the line and a third query point. We discovered, that when used with Python's float type [1 …

Python's super(): Not as Simple as You Thought

Posted on Fri 20 June 2014 by Austin Bingham

Python's super() is one of those aspects of the language that many developers use without really understanding what it does or how it works. [1] To many people, super() is simply how you access your base-class's implementation of a method. And while this is true, it's far from the full …

The Folly of Floating-Point for Robust Geometric Computation

Posted on Fri 20 June 2014 by Rob Smallshire

Computational geometry - a world where lines have zero thickness, circles are perfectly round and points are dimensionless. Creating robust geometric algorithms using finite precision number types such as float is fiendishly difficult because it's not possible to exactly represent numbers such as one-third, which rather gets in the way of …

How to write Boost.Python type converters

Posted on Fri 25 April 2014 by Austin Bingham

Boost.Python [1] makes it possible to write C++ that "feels" like Python. The library is powerful and sometimes subtle. This is as compared with the Python C API, where the experience is very far removed from writing Python code.

Part of making C++ feel more like Python is allowing …

« Page 2 / 2