Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Copy even immutable objects as much as possible
morecopy is a Python package that enables copy of immutable objects so that a copied object is equivalent but not identical to the original:
from morecopy import copy
original = 1234567890
copied = copy(original)
original == copied # -> True
original is copied # -> False
Note In general, there is no need to copy immutable objects, so this package may not be necessary in most cases. Also, some objects may not be copied even with this package: In CPython, for example, integers from -5 to 256 are always uncopied for optimization.
$ pip install morecopy
The following types are supported.
For mutable types (e.g. list
) or unsupported immutable types (e.g. bool
, NoneType
), morecopy.copy
and morecopy.deepcopy
are equivalent to copy.copy
and copy.deepcopy
, respectively.
Type | morecopy.copy | morecopy.deepcopy |
---|---|---|
int | yes | n/a |
float | yes | n/a |
complex | yes | n/a |
str | yes | n/a |
bytes | yes | n/a |
tuple | yes | n/a |
range | yes | n/a |
slice | yes | n/a |
frozenset | yes | n/a |
FunctionType | yes | n/a |
LambdaType | yes | n/a |
Users can add a custom copy function (copier) for a type.
For example, the following code defines copy of integer by creating a copy function and registering it by the copier_for
decorator.
from morecopy import copier_for
@copier_for(int)
def copy_int(integer: int) -> int:
return eval(repr(integer))
FAQs
Copy even immutable objects as much as possible
We found that morecopy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.