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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Source

File details

Details for the file tcopy-0.1.2.tar.gz.

File metadata

  • Download URL: tcopy-0.1.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tcopy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8401bdbd19d3d27266191a007087c610eb3539f2d025bdf9a1ed5167133ba930
MD5 a58fd1799016b61a32a0528c9e97db5e
BLAKE2b-256 29d2852a474f5605a5263380b9176d44692508ac9f0b12ed4b9df0064a1a2b11

See more details on using hashes here.

File details

Details for the file tcopy-0.1.2.macosx-10.10-intel.exe.

File metadata

File hashes

Hashes for tcopy-0.1.2.macosx-10.10-intel.exe
Algorithm Hash digest
SHA256 4bf9dc043e393f0be28ae944abd0cd5a11c0d24e52f0aac13ce2c54fb901780c
MD5 b1a41d509c4225fc4ea9e1cc2eea1a10
BLAKE2b-256 47e7ffbc7e8c378d5f9012d5b953b253847bed80d61ecdef5bec56f19332199a

See more details on using hashes here.

Supported by

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