Pass By Value
Passing by value in Python function arguments.
Overview
Python generally implements so called pass by object reference, that is to say, everything in Python is an object and within a function call arguments are mere references to those objects in memory. This is dangerous, because you can modify things without knowing you did. This library allows us to circumvent this behaviour in a simple decorator.
Usage
from pass_by_value import pass_by_value
@pass_by_value
def modify_list(lst):
lst[0] = 'a'
original_list = [1,2,3,4,5]
modified_list = modify_list(original_list)
original_list # [1,2,3,4,5]
modified_list # ['a',2,3,4,5]
Notes
- This library is currently very minimal and relies on
deepcopyto copy different structures before passing them to functions - Keep in mind that if you are passing a value you are necessarily passing a copy, so if you pass big objects/structures by value you might run out of memory
Metadata
Release files for pass-by-value 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pass_by_value-0.1.0.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pass_by_value-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.3 kB
Release files / pass_by_value-0.1.0.tar.gz
| Download URL | pass_by_value-0.1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7abd716b6c98c5ea7bf5add2d7b2c77e62ceec30f2ec5c21214e72b16d13ddef
|
|
BLAKE2b-256 checksum How to use checksums |
0a49dbbad4e6205f5023bee4ada00170a9c907f7d0c33e21b72e76cc33a02342
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.13
|
Release files / pass_by_value-0.1.0-py3-none-any.whl
| Download URL | pass_by_value-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f554deb23ec75580547b329f71074f776096403120a255e85131b4b3c091e8d9
|
|
BLAKE2b-256 checksum How to use checksums |
253e9e7d3ed72dfa25b7b8715290dbcaa1ba797636b2c69320ded4416ab5aedf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.13
|