Docs / Strand / advanced/python-snippet-resource-limits
Python Snippet Resource Limits
Python snippets have resource limits that ensure fair usage and prevent resource exhaustion. These limits scale with your account plan.
Resource Limits
| Resource | Description | Free | Starter | Standard | Pro |
|---|---|---|---|---|---|
| Code Size | Maximum size of your Python snippet code | 10,000 chars | 15,000 | 25,000 | 50,000 |
| Execution Time | Maximum seconds your code can run before being terminated | 5 s | 10 s | 30 s | 60 s |
| Memory | Maximum memory your code can use during execution | 50 MB | 128 MB | 256 MB | 512 MB |
| Output Size | Maximum size of data your code can return | 1 MB | 2 MB | 5 MB | 10 MB |
| File Size | Maximum size of any temporary file your code writes | 1 MB | 2 MB | 5 MB | 10 MB |
See tendrl.com/pricing for current plan details.
Note
These limits are enforced in the hosted runtime. A local development environment may not enforce them.
What Happens When Limits Are Exceeded?
If your code exceeds any limit, execution will be terminated and an error will be returned:
- Code Size: "Code size exceeds maximum allowed size"
- Execution Time: "Code execution exceeded time limit"
- Memory: "Code execution exceeded memory limit"
- Output Size: "Output size exceeds maximum allowed size"
- File Size: writing a temporary file larger than the limit is blocked
Best Practices
Tips for Staying Within Limits
- Code Size:
- Use helper functions to reduce duplication
- Keep code focused on single purpose
- Remove unnecessary comments if approaching limit
- Execution Time:
- Use efficient algorithms (O(n log n) vs O(n²))
- Process data in batches if needed
- Avoid nested loops on large datasets
- Consider splitting complex operations into multiple snippets
- Memory:
- Process data in chunks when possible
- Use generators instead of lists for large datasets
- Avoid keeping multiple copies of large data structures
- Clear variables when done with them
- Output Size:
- Return only necessary data
- Consider pagination for large result sets
- Use summaries instead of full datasets when possible
See Also
- Python Snippet Security & Variable Access - Security overview
Tendrl