References & Further Reading
References
- L. Ramalho, Fluent Python, O'Reilly Media, 2022
Chapters 11-14 on interfaces, inheritance, and operator overloading are the definitive Python-specific treatment. The coverage of ABCs, virtual subclasses, and the `__init_subclass__` hook is particularly thorough.
- E. Gamma, R. Helm, R. Johnson, and J. Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, 1994
The classic "Gang of Four" book. The Strategy, Template Method, and Composite patterns from this chapter originate here. While the examples are in C++/Smalltalk, the patterns translate directly to Python.
- C. R. Harris et al., Array programming with NumPy, Nature, 2020
The definitive reference for NumPy's architecture, including the array protocol dispatch mechanism (`__array_ufunc__`, `__array_function__`). Section 3 covers the protocol system.
- I. Levkivskyi, J. Lehtosalo, and L. Pluber, PEP 544 β Protocols: Structural subtyping (static duck typing), 2017
The proposal that introduced `typing.Protocol` to Python. Explains the motivation for structural subtyping and how it complements ABCs for static type checking.
- S. Hoyer et al., NEP 18 β A dispatch mechanism for NumPy's high level array functions, 2019
Defines the `__array_function__` protocol that enables libraries like Dask, CuPy, and JAX to override NumPy functions. Essential reading for building NumPy-compatible array types.
- R. C. Martin, Agile Software Development: Principles, Patterns, and Practices, Prentice Hall, 2003
Comprehensive treatment of SOLID principles including the Liskov Substitution Principle and Dependency Inversion Principle, which underpin the design patterns in this chapter.
- Python Software Foundation, Python 3.12 Documentation β abc, 2024
Official documentation for `abc.ABC`, `@abstractmethod`, `ABCMeta`, `register()`, and virtual subclasses.
Further Reading
NumPy array protocols in depth
NumPy documentation β Interoperability with NumPy (https://numpy.org/doc/stable/reference/arrays.classes.html)
Comprehensive reference for `__array__`, `__array_ufunc__`, `__array_function__`, and `__array_priority__`. Includes decision flowcharts for when each protocol is called.
Composition patterns in scientific Python
scikit-learn documentation β Developing scikit-learn estimators
scikit-learn's estimator API is a masterclass in composition over inheritance. The Pipeline, ColumnTransformer, and FeatureUnion classes demonstrate how to compose independent transformers.
Protocol-oriented design in typed Python
mypy documentation β Protocols and structural subtyping
Deep dive into how mypy checks protocol conformance, including covariance/contravariance of method signatures, protocol inheritance, and generic protocols.
GPU array interoperability
CuPy documentation β Interoperability (https://docs.cupy.dev/en/stable/user_guide/interoperability.html)
Explains `__cuda_array_interface__`, DLPack, and how CuPy achieves zero-copy data exchange with PyTorch, Numba, and other GPU libraries. Essential for Chapter 10 (GPU Computing).