Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@lazy A decorator to create lazy attributes.
Lazy attributes are computed attributes that are evaluated only once, the first time they are used. Subsequent uses return the results of the first call. They come handy when code should run
You can think of it as deferred initialization. The possibilities are endless.
The decorator is fully typed. Type checkers can infer the type of a lazy attribute from the return value of the decorated method.
The class below creates its store
resource lazily:
.. code-block:: python
from lazy import lazy
class FileUploadTmpStore(object):
@lazy
def store(self):
location = settings.get('fs.filestore')
return FileSystemStore(location)
def put(self, uid, fp):
self.store.put(uid, fp)
fp.seek(0)
def get(self, uid, default=None):
return self.store.get(uid, default)
def close(self):
if 'store' in self.__dict__:
self.store.close()
Another application area is caching:
.. code-block:: python
class PersonView(View):
@lazy
def person_id(self):
return self.request.get('person_id', -1)
@lazy
def person_data(self):
return self.session.query(Person).get(self.person_id)
For further details please refer to the API Documentation
_.
.. _API Documentation
: https://lazy.readthedocs.io/en/stable/
Implement lazy.__set_name__()
which helps in cases like
foo=lazy(_foo)
.
[stefan]
Update tox.ini for latest tox. [stefan]
Add GitHub CI workflow. [stefan]
Add .readthedocs.yaml file. [stefan]
Pin sphinx and sphinx-rtd-theme versions in docs extra. [stefan]
Add mypy extra which installs mypy. [stefan]
Fix stray characters in keywords. [stefan]
Allow type checkers to infer the type of a lazy attribute. Thanks to Elias Keis and Palpatineli for their contributions. [elKei24] [Palpatineli]
Add Python 3.8-3.11 to tox.ini. Remove old Python versions. [stefan]
Replace deprecated python setup.py test
in tox.ini.
[stefan]
Remove deprecated test_suite
from setup.py.
[stefan]
Move metadata to setup.cfg and add a pyproject.toml file. [stefan]
Include tests in sdist but not in wheel. [stefan]
Add MANIFEST.in. [stefan]
Release as universal wheel. [stefan]
Support Python 2.6-3.6 without 2to3. [stefan]
Add a LICENSE file. [stefan]
functools.wraps()
properly; the list of attributes changes with
every version of Python 3.
[stefan]FAQs
Lazy attributes for Python objects
We found that lazy 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.