Metadata-Version: 2.1
Name: pass-by-value
Version: 0.1.0
Summary: Passing by value in Python functions
Home-page: https://github.com/petereon/pass_by_val
License: MIT
Keywords: python
Author: Peter Vyboch
Author-email: pvyboch1@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.9
Project-URL: Repository, https://github.com/petereon/pass_by_val
Description-Content-Type: text/markdown

# 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

```python

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 `deepcopy` to 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

