GILBypass


NameGILBypass JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/IHasBone/GILB
SummaryGILBypass (GILB) is a module that allows you to bypass the Global Interpreter Lock (GIL) in Python.
upload_time2023-06-09 14:48:56
maintainer
docs_urlNone
authorIHasBone
requires_python>=3.10
licenseMIT
keywords gil bypass gilbypass gilb global interpreter lock
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            *GILBypass* (GILB) is a python package that allows you to bypass the Global Interpreter Lock (GIL) in Python. GILB stands for Global Interpreter Lock Bypass. The GIL makes it so that only one thread can run at a time. This is a problem for programs that are CPU bound, because they can't use multiple cores. GILB allows you to bypass the GIL and use multiple cores.

Installation:
-
```shell
pip install GILBypass
```

Import as:
-
```python
import GILB
```

Example program:
-
```python
from GILB import bypass

if __name__ == '__main__':
    bypass('file.py', 10, gilb_chunk='chunk', gilb_global='global', gilb_header='header', gilb_footer='footer')
```
In this example, the file 'file.py' will be run using 10 processes. The file looks like this:
```python
# global
import time
# global

# header
import time
start = time.time()
# header

# footer
end = time.time() - start
print("Finished in", end, "seconds.")
# footer

time.sleep(1)
print("1 Finished Sleeping")
# chunk
time.sleep(1)
print("2 Finished Sleeping")
# chunk
time.sleep(1)
print("3 Finished Sleeping")
# chunk
time.sleep(1)
print("4 Finished Sleeping")
# chunk
time.sleep(1)
print("5 Finished Sleeping")
# chunk
time.sleep(1)
print("6 Finished Sleeping")
# chunk
time.sleep(1)
print("7 Finished Sleeping")
```
The output is the following:
```shell
1 Finished Sleeping
Finished in 1.0006422996520996 seconds.
2 Finished Sleeping
Finished in 1.000640630722046 seconds.
4 Finished Sleeping
Finished in 1.0006122589111328 seconds.
5 Finished Sleeping
Finished in 1.0001180171966553 seconds.
6 Finished Sleeping
Finished in 1.000612497329712 seconds.
7 Finished Sleeping
Finished in 1.000640630722046 seconds.
3 Finished Sleeping
Finished in 1.000584363937378 seconds.
```
Note that it can be in another order. This is because the processes are running at the same time.
Global is code that every process can access. It is run in every process, so the processes don't share globals.
Header is code that is at the top of the execution. It is run once in every process.
Footer is code that is at the bottom of the execution. It is run once in every process.

NOTE: The 'global' cannot access the 'header' or 'footer'. The 'header' and 'footer' cannot access the 'global'. The 'footer' can access the 'header'.

---
**All the parameters for GILB.bypass() are:**
* file: Relative or absolute path to the file to be run.
* processes: The amount of processes to run. If the amount of chunks is smaller than the amount of processes, processes=len(chunks). Defaults to multiprocessing.cpu_count()
* executor: The function to execute the code. Defaults to pythons built-in 'exec'.
* gilb_global: Name for the global tag. Defaults to 'gilb:global'
* gilb_chunk: Name for the global tag. Defaults to 'gilb:chunk'
* gilb_header: Name for the global tag. Defaults to 'gilb:header'
* gilb_footer: Name for the global tag. Defaults to 'gilb:footer'

---
# Ideas
* Have some kind of return value.
* Be able to bypass the file without a special syntax.
* Make it possible to have a shared resource, that all processes can access.
* Make it possible to use the file as a module (import it and use its functions).

---
### For more functionality, visit the [GitHub](https://github.com/IHasBone/GILB).


# Changelog


### 0.1.0 (09/06/2023)
* First Release

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/IHasBone/GILB",
    "name": "GILBypass",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "GIL,bypass,GILBypass,GILB,global interpreter lock",
    "author": "IHasBone",
    "author_email": "info@picstreme.com",
    "download_url": "https://files.pythonhosted.org/packages/16/8c/d0feb6498163cdafb527490f42804e9cd6a0b3a2ec99b32e55c70497f218/GILBypass-0.1.0.tar.gz",
    "platform": null,
    "description": "*GILBypass* (GILB) is a python package that allows you to bypass the Global Interpreter Lock (GIL) in Python. GILB stands for Global Interpreter Lock Bypass. The GIL makes it so that only one thread can run at a time. This is a problem for programs that are CPU bound, because they can't use multiple cores. GILB allows you to bypass the GIL and use multiple cores.\r\n\r\nInstallation:\r\n-\r\n```shell\r\npip install GILBypass\r\n```\r\n\r\nImport as:\r\n-\r\n```python\r\nimport GILB\r\n```\r\n\r\nExample program:\r\n-\r\n```python\r\nfrom GILB import bypass\r\n\r\nif __name__ == '__main__':\r\n    bypass('file.py', 10, gilb_chunk='chunk', gilb_global='global', gilb_header='header', gilb_footer='footer')\r\n```\r\nIn this example, the file 'file.py' will be run using 10 processes. The file looks like this:\r\n```python\r\n# global\r\nimport time\r\n# global\r\n\r\n# header\r\nimport time\r\nstart = time.time()\r\n# header\r\n\r\n# footer\r\nend = time.time() - start\r\nprint(\"Finished in\", end, \"seconds.\")\r\n# footer\r\n\r\ntime.sleep(1)\r\nprint(\"1 Finished Sleeping\")\r\n# chunk\r\ntime.sleep(1)\r\nprint(\"2 Finished Sleeping\")\r\n# chunk\r\ntime.sleep(1)\r\nprint(\"3 Finished Sleeping\")\r\n# chunk\r\ntime.sleep(1)\r\nprint(\"4 Finished Sleeping\")\r\n# chunk\r\ntime.sleep(1)\r\nprint(\"5 Finished Sleeping\")\r\n# chunk\r\ntime.sleep(1)\r\nprint(\"6 Finished Sleeping\")\r\n# chunk\r\ntime.sleep(1)\r\nprint(\"7 Finished Sleeping\")\r\n```\r\nThe output is the following:\r\n```shell\r\n1 Finished Sleeping\r\nFinished in 1.0006422996520996 seconds.\r\n2 Finished Sleeping\r\nFinished in 1.000640630722046 seconds.\r\n4 Finished Sleeping\r\nFinished in 1.0006122589111328 seconds.\r\n5 Finished Sleeping\r\nFinished in 1.0001180171966553 seconds.\r\n6 Finished Sleeping\r\nFinished in 1.000612497329712 seconds.\r\n7 Finished Sleeping\r\nFinished in 1.000640630722046 seconds.\r\n3 Finished Sleeping\r\nFinished in 1.000584363937378 seconds.\r\n```\r\nNote that it can be in another order. This is because the processes are running at the same time.\r\nGlobal is code that every process can access. It is run in every process, so the processes don't share globals.\r\nHeader is code that is at the top of the execution. It is run once in every process.\r\nFooter is code that is at the bottom of the execution. It is run once in every process.\r\n\r\nNOTE: The 'global' cannot access the 'header' or 'footer'. The 'header' and 'footer' cannot access the 'global'. The 'footer' can access the 'header'.\r\n\r\n---\r\n**All the parameters for GILB.bypass() are:**\r\n* file: Relative or absolute path to the file to be run.\r\n* processes: The amount of processes to run. If the amount of chunks is smaller than the amount of processes, processes=len(chunks). Defaults to multiprocessing.cpu_count()\r\n* executor: The function to execute the code. Defaults to pythons built-in 'exec'.\r\n* gilb_global: Name for the global tag. Defaults to 'gilb:global'\r\n* gilb_chunk: Name for the global tag. Defaults to 'gilb:chunk'\r\n* gilb_header: Name for the global tag. Defaults to 'gilb:header'\r\n* gilb_footer: Name for the global tag. Defaults to 'gilb:footer'\r\n\r\n---\r\n# Ideas\r\n* Have some kind of return value.\r\n* Be able to bypass the file without a special syntax.\r\n* Make it possible to have a shared resource, that all processes can access.\r\n* Make it possible to use the file as a module (import it and use its functions).\r\n\r\n---\r\n### For more functionality, visit the [GitHub](https://github.com/IHasBone/GILB).\r\n\r\n\r\n# Changelog\r\n\r\n\r\n### 0.1.0 (09/06/2023)\r\n* First Release\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "GILBypass (GILB) is a module that allows you to bypass the Global Interpreter Lock (GIL) in Python.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/IHasBone/GILB"
    },
    "split_keywords": [
        "gil",
        "bypass",
        "gilbypass",
        "gilb",
        "global interpreter lock"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "168cd0feb6498163cdafb527490f42804e9cd6a0b3a2ec99b32e55c70497f218",
                "md5": "da79cfdbd208d1df9e3e44bf2a63edb7",
                "sha256": "6916af1e55ea103e58f42782f32775706619fc03ad6fc833acce4de535da9d64"
            },
            "downloads": -1,
            "filename": "GILBypass-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "da79cfdbd208d1df9e3e44bf2a63edb7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 4253,
            "upload_time": "2023-06-09T14:48:56",
            "upload_time_iso_8601": "2023-06-09T14:48:56.059303Z",
            "url": "https://files.pythonhosted.org/packages/16/8c/d0feb6498163cdafb527490f42804e9cd6a0b3a2ec99b32e55c70497f218/GILBypass-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-09 14:48:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "IHasBone",
    "github_project": "GILB",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "gilbypass"
}
        
Elapsed time: 0.09757s