+x

Looks like dead code, and on int and float it is. It survives because __pos__ is a hook — Decimal and Counter both use it for something real.

Arithmetic operatorPython 1.0+Live demo
Common call
+x
Returns
the same value for int and float
Replaces
nothing, on ordinary numbers
Watch out
on Decimal it applies rounding; on Counter it drops non-positive counts
+aa — Operand. Any type defining __pos__ works; str and list do not.type: number · required
→ number

Demo

Live evaluation
Try:
Inputs
afloatvalue
Output
+5
5

On ordinary numbers unary plus does nothing at all — a negative stays negative, and the value comes back unchanged. That is the point worth internalising: it does NOT make a number positive. Its reason for existing is that it calls __pos__, and a few standard-library types use that hook to do genuinely useful work.

Operands

NameTypeRequiredDescription
anumberyesOperand. Any type defining __pos__ works; str and list do not.

Return value

number — The operand, generally unchanged. Calls __pos__, which some types use to do real work.

Common patterns

Drop non-positive counts from a Counter
The best-known real use of unary plus in the standard library.
from collections import Counter
c = Counter(a=3, b=-1, c=0)
positive_only = +c   # Counter({"a": 3})
Apply Decimal context rounding
Forces the current context precision onto a value.
from decimal import Decimal, localcontext
with localcontext() as ctx:
    ctx.prec = 3
    rounded = +Decimal("1.23456")
Symmetry in generated code
Where a sign is inserted programmatically, + keeps the shape uniform.
expr = f"{sign}{value}"   # sign is "+" or "-"

Examples

1. Unchanged
+5
Returns
5
2. Stays negative
+(-5)
Returns
-5
3. Float
+2.5
Returns
2.5
4. Not abs
+(-5) == abs(-5)
Returns
False
5. bool becomes int
+True
Returns
1
6. Counter filters
from collections import Counter +Counter(a=3, b=-1)
Returns
Counter({'a': 3})

Pitfalls

1. It does not make a number positive
The single most common misreading. +x is not abs(x) — a negative operand comes back negative, silently, with no error to catch the mistake.
Still negative
+(-5)
-5
Use abs
abs(-5)
5
2. It is not always a no-op
On int and float it does nothing, which teaches people to ignore it. On Decimal it applies context rounding, and on Counter it strips zero and negative counts — deleting it there changes behaviour.
Assumed harmless
from collections import Counter
c = Counter(a=3, b=-1)
c   # without the +
Counter({'a': 3, 'b': -1})
The + matters
+c
Counter({'a': 3})
3. Not defined for str or list
Unary plus needs __pos__, which sequences lack. It is a TypeError rather than a harmless no-op, which surprises people who expect it to be ignorable.
No __pos__
+'abc'
TypeError: bad operand type for unary +: 'str'
Drop it
'abc'
'abc'
4. It converts bool to int
Like unary minus, it goes through the numeric protocol, so True comes back as 1 rather than True. An easy way to lose a boolean type by accident.
Type changed
+True
1
Leave it alone
True
True

When to use

Use it
  • Filtering a Counter down to positive counts
  • Forcing Decimal context rounding onto a value
  • Generated or templated code where a leading sign keeps the shape uniform
Reach for something else
  • Making a number positive → abs
  • Ordinary arithmetic on int and float — it does nothing
  • Sequences, where it raises rather than being ignored

Notes

Complexity
O(1) for numbers; whatever __pos__ costs for custom types
Return
For int and float, CPython may return the same object; bool becomes int
CPython impl
Objects/abstract.c :: PyNumber_Positive, dispatching to __pos__
Memory
Usually no allocation for built-in numbers
Thread-safe
Yes — numbers are immutable

FAQ

It exists so types can hook __pos__. Counter uses it to drop non-positive counts, and Decimal uses it to apply the current context precision. On plain numbers it is genuinely a no-op — the operator is there for the types that need it.

+Counter(a=3, b=-1)
# Counter({"a": 3})

History

1.0
Unary plus present since the earliest Python.
3.3
Counter gained the unary + form for stripping non-positive counts.