# TimeSpaceX
A powerful Python Time and Space Complexity Analyzer that helps you understand the computational complexity of your code.
## Features
- Analyzes both time and space complexity
- Provides detailed explanations
- Detects common patterns:
- Simple loops (O(n))
- Nested loops (O(n²), O(n³))
- Binary search patterns (O(log n))
- Divide and conquer algorithms (O(n log n))
- Recursive functions
- Matrix operations
- Beautiful command-line interface with syntax highlighting
## Installation
```bash
pip install timespacex
```
## Usage
Analyze a Python file:
```bash
timespacex your_file.py
```
Options:
```bash
timespacex --no-color your_file.py # Disable colored output
```
## Example
Given a Python file `example.py` with the following content:
```python
def binary_search(arr, target):
left, right = 0, len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
```
Running:
```bash
timespacex example.py
```
Will output:
```
Time & Space Complexity Analysis
==================================================
┌─ Function: binary_search ──────────────────────┐
│ The function `binary_search` has a time │
│ complexity of O(log n). This is because the │
│ function uses a binary search pattern, │
│ dividing the search space in half at each │
│ step. │
│ │
│ The space complexity is O(1). This is because │
│ the function uses a constant amount of extra │
│ space regardless of input size. │
└───────────────────────────────────────────────┘
```
## Limitations
- The analysis is based on static code analysis and may not catch all edge cases
- Complex algorithmic patterns might not be accurately detected
- The tool provides simplified complexity analysis and may not catch subtle optimizations
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the LICENSE file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/hamedyaghoobian/timespacex",
"name": "timespacex",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "complexity analysis, big o notation, algorithm analysis, time complexity, space complexity",
"author": "Hamed Yaghoobian",
"author_email": "hamedyaghoobian@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/66/b3/702b074d5ab916a30b69c80b80d96c40c326cf026031c4217138e91dd374/timespacex-0.1.0.tar.gz",
"platform": null,
"description": "# TimeSpaceX\n\nA powerful Python Time and Space Complexity Analyzer that helps you understand the computational complexity of your code.\n\n## Features\n\n- Analyzes both time and space complexity\n- Provides detailed explanations\n- Detects common patterns:\n - Simple loops (O(n))\n - Nested loops (O(n\u00b2), O(n\u00b3))\n - Binary search patterns (O(log n))\n - Divide and conquer algorithms (O(n log n))\n - Recursive functions\n - Matrix operations\n- Beautiful command-line interface with syntax highlighting\n\n## Installation\n\n```bash\npip install timespacex\n```\n\n## Usage\n\nAnalyze a Python file:\n```bash\ntimespacex your_file.py\n```\n\nOptions:\n```bash\ntimespacex --no-color your_file.py # Disable colored output\n```\n\n## Example\n\nGiven a Python file `example.py` with the following content:\n\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return -1\n```\n\nRunning:\n```bash\ntimespacex example.py\n```\n\nWill output:\n```\nTime & Space Complexity Analysis\n==================================================\n\n\u250c\u2500 Function: binary_search \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 The function `binary_search` has a time \u2502\n\u2502 complexity of O(log n). This is because the \u2502\n\u2502 function uses a binary search pattern, \u2502\n\u2502 dividing the search space in half at each \u2502\n\u2502 step. \u2502\n\u2502 \u2502\n\u2502 The space complexity is O(1). This is because \u2502\n\u2502 the function uses a constant amount of extra \u2502\n\u2502 space regardless of input size. \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n## Limitations\n\n- The analysis is based on static code analysis and may not catch all edge cases\n- Complex algorithmic patterns might not be accurately detected\n- The tool provides simplified complexity analysis and may not catch subtle optimizations\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details. \n",
"bugtrack_url": null,
"license": null,
"summary": "A Python Time and Space Complexity Analyzer",
"version": "0.1.0",
"project_urls": {
"Bug Reports": "https://github.com/hamedyaghoobian/timespacex/issues",
"Homepage": "https://github.com/hamedyaghoobian/timespacex",
"Source": "https://github.com/hamedyaghoobian/timespacex"
},
"split_keywords": [
"complexity analysis",
" big o notation",
" algorithm analysis",
" time complexity",
" space complexity"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d4a3f7b774ce86222af5928df3ee0111809686ed9cdc8bcc5d6755a7216277be",
"md5": "3529e0b0246a4154cb19fafe6526b534",
"sha256": "a7fe635221e353dc0c073e2cf17cee41fcaa6e503e9cbbbabaf97a5de55129ba"
},
"downloads": -1,
"filename": "timespacex-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3529e0b0246a4154cb19fafe6526b534",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 6548,
"upload_time": "2024-12-29T06:40:43",
"upload_time_iso_8601": "2024-12-29T06:40:43.618936Z",
"url": "https://files.pythonhosted.org/packages/d4/a3/f7b774ce86222af5928df3ee0111809686ed9cdc8bcc5d6755a7216277be/timespacex-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "66b3702b074d5ab916a30b69c80b80d96c40c326cf026031c4217138e91dd374",
"md5": "6a0b83208caf24f59bfecb184b158cfb",
"sha256": "b04aa69b9d143e16603f8dacc1bd798e97711665505b6bb2e9c4945bb4a2eb19"
},
"downloads": -1,
"filename": "timespacex-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "6a0b83208caf24f59bfecb184b158cfb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 6019,
"upload_time": "2024-12-29T06:40:47",
"upload_time_iso_8601": "2024-12-29T06:40:47.734912Z",
"url": "https://files.pythonhosted.org/packages/66/b3/702b074d5ab916a30b69c80b80d96c40c326cf026031c4217138e91dd374/timespacex-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-29 06:40:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hamedyaghoobian",
"github_project": "timespacex",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "timespacex"
}