Skip to main content

Basic tail call removal decorator

Project description

# tcopy

_Do not use this._

A direct tail call optimizing decorator for Python.

## Examples:

```python
from tcopy import tco

@tco
def fib(n, x=0, y=1):
if n == 0:
return x
return fib(n - 1, y, x + y)
```

The `tco` decorator will rewrite `fib` into the following at
definition time:

```python
def fib(n, x=0, y=1):
while 1:
if n == 0:
return x
n, x, y = n - 1, y, x + y
```

## Quirks

`tco` uses `inspect.getsource` to grab a function's source code from
disk. Because of this, the decorator does not work in the Python REPL.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tcopy-0.1.2.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

tcopy-0.1.2.macosx-10.10-intel.exe (65.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page