Skip to content

Conversation

@michaelj094
Copy link

@michaelj094 michaelj094 commented Jan 9, 2026

Summary

This PR adds a Pythonic implementation of the Pipeline (Functional Pipeline) pattern to the repository.

The example demonstrates how sequential data processing can be composed using callables, iterables, and generators, instead of class-heavy or framework-style abstractions. The goal is to provide a clear, minimal reference that aligns with common Python idioms.

Motivation

While the repository includes many classic GoF and architectural patterns, it did not previously contain a dedicated example of the Pipeline pattern, which is widely used in Python for:

  • data processing and ETL workflows
  • generator-based stream transformations
  • middleware-style request/response chains

Adding this pattern fills a practical gap and reflects how Python developers commonly structure such flows.

Files Changed

Added

  • patterns/behavioral/pipeline.py
    Adds a Pythonic implementation of the Pipeline (Functional Pipeline) pattern,
    including a short TL;DR, minimal implementation, and runnable example.

  • tests/test_pipeline.py
    Adds a small test to verify pipeline composition and behavior.

Changed

  • README.md
    Adds pipeline to the list of behavioral patterns.

Design & Implementation

The implementation focuses on simplicity and readability:

  • Each pipeline stage is a callable transforming an Iterable into another Iterable
  • Generator-based stages enable lazy evaluation and efficient processing
  • A small compose helper connects stages left-to-right
  • A lightweight Pipeline wrapper is included for convenience without introducing complex abstractions
  • The module contains a short TL;DR and a runnable example

Example

The included demonstration builds a pipeline that:

  1. filters even numbers
  2. squares them
  3. takes the first three results

This illustrates how small, reusable stages can be combined into a readable data flow.

Testing

The behavior was verified by running the example included in the module.

Doc

Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=191372963

@michaelj094
Copy link
Author

Hi @faif

Thanks for maintaining this repository.

I’ve added a Pythonic example of the Pipeline (functional pipeline) pattern, focusing on
callable-based composition and generator-style stages, in line with the educational
and minimal style of the repo.

I’d appreciate your review when you have time. Any feedback or suggestions are very welcome.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant