# Pipe operator |\>

**URL:** <https://discuss.python.org/t/pipe-operator/94333>\
**Category:** Ideas\
**Created:** [June 3, 2025, 5:49pm UTC](https://discuss.python.org/t/pipe-operator/94333 "2025-06-03T17:49:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![elis.byberi](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/elis.byberi/32/35937_2.png) [@elis.byberi](https://discuss.python.org/u/elis.byberi)\
**Post date:** [June 3, 2025, 5:49pm UTC](https://discuss.python.org/t/pipe-operator/94333/1 "2025-06-03T17:49:57Z")

</div>

This is a counter-proposal to [another](https://discuss.python.org/t/introduce-funnel-operator-i-e-to-allow-for-generator-pipelines/67701) suggestion about introducing a pipe operator in Python. It’s not meant for inclusion in the language. The goal is simply to explore the idea on its own. I’m not interested in debating hypotheticals.

Please keep the discussion focused on the [proposal](https://docs.exaloop.io/codon/advanced/pipelines) itself:

```python
def add1(x):
    return x + 1

2 |> add1 # 3; equivalent to add1(2)

def calc(x, y):
    return x + y**2
2 |> calc(3) # 11; equivalent to calc(2, 3)
2 |> calc(..., 3) # 11; equivalent to calc(2, 3)
2 |> calc(3, ...) # 7; equivalent to calc(3, 2)

def gen(i):
    for i in range(i):
        yield i

5 |> gen |> print # prints 0 1 2 3 4 separated by newline
range(1, 4) |> iter |> gen |> print(end=' ') # prints 0 0 1 0 1 2 without newline
[1, 2, 3] |> print # prints [1, 2, 3]
range(100000000) |> print # prints range(0, 100000000)
range(100000000) |> iter |> print # not only prints all those numbers, but it uses almost no memory at all

```

The proposal is intentionally left without further explanation. Either the reader understands what’s going on, or the syntax is unclear.

Feedback on the proposal is welcome.

---

<div class="post-metadata">

**Author:** ![tstefan](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tstefan](https://discuss.python.org/u/tstefan)\
**Post date:** [June 3, 2025, 6:03pm UTC](https://discuss.python.org/t/pipe-operator/94333/2 "2025-06-03T18:03:12Z")

</div>

> [@elis.byberi](#):
>
> The goal is simply to explore the idea on its own.

Since you don’t specify syntax and semantics, there is nothing to explore here.

> [@elis.byberi](#):
>
> It’s not meant for inclusion in the language.

Why should anyone care then?

---

<div class="post-metadata">

**Author:** ![elis.byberi](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/elis.byberi/32/35937_2.png) [@elis.byberi](https://discuss.python.org/u/elis.byberi)\
**Post date:** [June 3, 2025, 6:10pm UTC](https://discuss.python.org/t/pipe-operator/94333/3 "2025-06-03T18:10:50Z")

</div>

> [@tstefan](#):
>
> > [@elis.byberi](#):
> >
> > It’s not meant for inclusion in the language.
> 
> Why should anyone care then?

I should have been clearer. I’m not in favor of including it in the language, but I’m open to discussing it here. This thread could serve as the platform for presenting arguments both against and in favor of its inclusion.

---

<div class="post-metadata">

**Author:** ![dg-pb](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dg-pb/32/16248_2.png) [@dg-pb](https://discuss.python.org/u/dg-pb)\
**Post date:** [June 3, 2025, 6:34pm UTC](https://discuss.python.org/t/pipe-operator/94333/4 "2025-06-03T18:34:13Z")

</div>

> [@elis.byberi](#):
>
> `2 |> calc(3) # 11; equivalent to calc(2, 3)`

Not sure if it should be `calc(2, 3)` or `calc(3, 2)`. The latter would be more in line with `partial`.

> [@elis.byberi](#):
>
> `2 |> calc(..., 3)`

There were variants of `Ellipsis` placeholders in `PyPI` when I was researching potential directions for `partial`. There is quite a big inconvenience with arbitrary number of values on the left - it’s signature is unclear and such construct is unlikely to go through to standard library on its own as an independent component.

But this is same as current explorations in [Introduce funnel operator i,e '|\>' to allow for generator pipelines - #237 by sadaszewski](https://discuss.python.org/t/introduce-funnel-operator-i-e-to-allow-for-generator-pipelines/67701/237) - it seems to be a proposal for monolithic construct. For such, I believe the signature will never have to be inferred programatically (and `typing` could infer things from the whole construct), so not as big of an issue, but nevertheless - keeping things consistent whenever possible is of long term benefit IMO.

---

<div class="post-metadata">

**Author:** ![pf\_moore](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pf_moore/32/35_2.png) [@pf\_moore](https://discuss.python.org/u/pf_moore)\
**Post date:** [June 3, 2025, 6:36pm UTC](https://discuss.python.org/t/pipe-operator/94333/5 "2025-06-03T18:36:56Z")

</div>

> [@elis.byberi](#):
>
> The proposal is intentionally left without further explanation. Either the reader understands what’s going on, or the syntax is unclear.

OK, so the syntax is unclear. Without the comments, I wouldn’t be able to understand what the syntax does. With the comments, I can see what each individual statement does, but I can’t infer a general rule for how `|>` behaves.

The only feedback I can give is that this is pointless in its current (underspecified) form.

---

<div class="post-metadata">

**Author:** ![sadaszewski](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@sadaszewski](https://discuss.python.org/u/sadaszewski)\
**Post date:** [June 3, 2025, 7:33pm UTC](https://discuss.python.org/t/pipe-operator/94333/6 "2025-06-03T19:33:15Z")

</div>

Typing 3 characters instead of one is a major inconvenience. Default injection position (as the first argument) plays poorly with existing Python functions. Limitation to calls or callables on the RHS is a major inconvenience. This limitation allows to use just the callable name but don’t be fooled - this is translated into a call under the hood. As the others are saying, without a specification it’s not even possible to discuss it. Overall it feels like a “pipeline operator of the past century” not a pipeline operator of the future and as if the authors made all the worst possible choices at each and every junction. The lack of a magic method to override it is the nail in the coffin. It’s extremely limited compared to the state we achieved in the other thread. I am surprised it surfaced at this stage.

---

<div class="post-metadata">

**Author:** ![ambv](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ambv/32/25884_2.png) [@ambv](https://discuss.python.org/u/ambv)\
**Post date:** [June 3, 2025, 7:38pm UTC](https://discuss.python.org/t/pipe-operator/94333/7 "2025-06-03T19:38:07Z")

</div>

> [@elis.byberi](#):
>
> I’m not in favor of including it in the language, but I’m open to discussing it here.

This is therefore off-topic for this forum.

---

<div class="post-metadata">

**Author:** ![elis.byberi](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/elis.byberi/32/35937_2.png) [@elis.byberi](https://discuss.python.org/u/elis.byberi)\
**Post date:** [June 3, 2025, 7:49pm UTC](https://discuss.python.org/t/pipe-operator/94333/8 "2025-06-03T19:49:13Z")

</div>

The whole point here is that if syntax is really readable, you shouldn’t have to dig into a spec to figure it out.

---

<div class="post-metadata">

**Author:** ![elis.byberi](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/elis.byberi/32/35937_2.png) [@elis.byberi](https://discuss.python.org/u/elis.byberi)\
**Post date:** [June 3, 2025, 7:51pm UTC](https://discuss.python.org/t/pipe-operator/94333/9 "2025-06-03T19:51:30Z")

</div>

> [@sadaszewski](#):
>
> authors made all the worst possible choices at each and every junction

We’re not here to debate that. The design choices are well-suited to the language in question. The pipe operator works perfectly in Codon, but it doesn’t fit naturally in Python.

---

<div class="post-metadata">

**Author:** ![elis.byberi](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/elis.byberi/32/35937_2.png) [@elis.byberi](https://discuss.python.org/u/elis.byberi)\
**Post date:** [June 3, 2025, 8:02pm UTC](https://discuss.python.org/t/pipe-operator/94333/10 "2025-06-03T20:02:03Z")

</div>

This is more about giving the pipe operator a proper discussion. It is an idea in its own right, but this thread has already served its purpose.

---

<div class="post-metadata">

**Author:** ![ambv](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ambv/32/25884_2.png) [@ambv](https://discuss.python.org/u/ambv)\
**Post date:** [June 3, 2025, 8:09pm UTC](https://discuss.python.org/t/pipe-operator/94333/11 "2025-06-03T20:09:56Z")

</div>


