Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feat: Add Pythonic Pipeline pattern using functional composition #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
michaelj094 wants to merge 1 commit into faif:master
base: master
Choose a base branch
Loading
from michaelj094:feat/add-functional-pipeline-pattern

Conversation

@michaelj094
Copy link

@michaelj094 michaelj094 commented Jan 9, 2026
edited
Loading

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

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!

Copy link
Owner

faif commented Jan 15, 2026

Hi,

Thanks for the contribution. Can you fix the linter errors?

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /