# Clone computing
> Do it once.
This [[Anti-Pattern|anti-pattern]] happens when you perform an operation similar to a [[Pure Function]] (same input mean same output without side effects) multiple times to avoid creating a temporary [[Variable]]. It's easily solved with a [[Walrus Operator]].
```python
# Don't
if int(value) % 2 != 0:
do_stuff(int(value))
# Do
if (n:=int(value)) % 2 != 0:
do_stuff(n)
# Or (beginner friendly)
n = int(value)
if n % 2 != 0:
do_stuff(n)
```
```python
numbers = [1, 10, 42]
k = random.randrange(3)
# Don't
result = [
(n, k - n)
for i, n in enumerate(numbers)
if k - n in l[i + 1:] # `k - x` operation has a pure behavior
]
# Do
result = [
(n, complement)
for i, n in enumerate(numbers)
if (complement := k - n) in l[i + 1:]
]
```
Be careful not to fall into those other [[Anti-Pattern|anti-patterns]]:
- [[Non-scoped Walrus]]
- [[Needless temporary variable]]
---
Bibliography:
- [Title - website.com](need bibliography)