Memory efficient Python objects
Project description
Atom is a framework for creating memory efficient Python objects with enhanced features such as dynamic initialization, validation, and change notification for object attributes. It provides the default model binding behavior for the Enaml UI framework.
Examples:
from atom.api import Atom, Str, Range, Bool, observe
class Person(Atom):
""" A simple class representing a person object.
"""
last_name = Str()
first_name = Str()
age = Range(low=0)
debug = Bool(False)
@observe('age')
def debug_print(self, change):
""" Prints out a debug message whenever the person's age changes.
"""
if self.debug:
templ = "{first} {last} is {age} years old."
s = templ.format(
first=self.first_name, last=self.last_name, age=self.age,
)
print(s)
def _default_first_name(self):
return 'John'
john = Person(last_name='Doe', age=42)
john.debug = True
john.age = 43 # prints message
john.age = 'forty three' # raises TypeError
Starting with atom 0.8.0 atom object can also be defined using type annotations.
from atom.api import Atom, observe
class InventoryItem(Atom):
"""Class for keeping track of an item in inventory."""
name: str
unit_price: float
quantity_on_hand: int = 0
def total_cost(self) -> float:
return self.unit_price * self.quantity_on_hand
@observe("unit_price")
def check_for_price_reduction(self, change):
savings = change.get("oldvalue", 0) - change.get("value")
if savings > 0:
print(f"Save ${savings} now on {self.name}s!")
>>> w = InventoryItem(name="widget", unit_price=1.99, quantity_on_hand=10)
>>> w.unit_price = 1.00
Save $0.99 now on widgets!
For version information, see the Revision History.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
atom-0.8.0.tar.gz
(154.7 kB
view hashes)
Built Distributions
atom-0.8.0-cp310-cp310-win_amd64.whl
(124.5 kB
view hashes)
atom-0.8.0-cp310-cp310-win32.whl
(111.5 kB
view hashes)
atom-0.8.0-cp39-cp39-win_amd64.whl
(124.6 kB
view hashes)
atom-0.8.0-cp39-cp39-win32.whl
(111.7 kB
view hashes)
atom-0.8.0-cp38-cp38-win_amd64.whl
(124.5 kB
view hashes)
atom-0.8.0-cp38-cp38-win32.whl
(111.6 kB
view hashes)
Close
Hashes for atom-0.8.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86b3da524467a05759abcf7e10f59cf03db6296bb6143db83b5a2ea1779a7da3 |
|
MD5 | e143aecfcdbac16e4d111de007e7fbc0 |
|
BLAKE2b-256 | 4208acb2938f3054273193ce24378ea2e54560641bc99e641941034a701af9d9 |
Close
Hashes for atom-0.8.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40ace61a6e634bd3fe86603c891c6bd14c55c43850e93fd50232538cdb51bdd9 |
|
MD5 | aed5b7b294634ac9856655cc1fa45eb3 |
|
BLAKE2b-256 | dd7d18bb8f38964d1db6e31c702b522728de909eb5f6758941755c37dff08107 |
Close
Hashes for atom-0.8.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 195d580732eee5c1f264d09f4ee2c0ed4fb8acaa84569766233132fa00d56baf |
|
MD5 | f842c8dd366b8a5466ea545629866ebf |
|
BLAKE2b-256 | fe8c59de8139900bdc5c012cfe6d88fd82e79962800e615a5d71f8f05c08064c |
Close
Hashes for atom-0.8.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4764dd955c59ba239f61527ef399ea1d716f7ccc8376b0fc10309ddf99aeefa |
|
MD5 | 4687af553eed37e6ea36ecf43373d58a |
|
BLAKE2b-256 | 30d136e3b8735b96a02cd6282befb1f0e0f6dca0d3152929af40a21e92039dfa |
Close
Hashes for atom-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4437427de514844fddaa4ed9281d30a96d4605702e1483ae6126ceb0cf58b7a |
|
MD5 | c89b30e4facfec19962911c1899ad859 |
|
BLAKE2b-256 | dd3594fc3433f7716bda2531d7da1eef0cb28f7cf3a2012a6fc9e880230f68dc |
Close
Hashes for atom-0.8.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79c5f3952896c13ce4a8a88f326809db099a5a718b5c7f4046787ffac14a90cc |
|
MD5 | 85aa2b83284384b623de9f2513dce387 |
|
BLAKE2b-256 | f1fca47cd61210a3effa5bf62e3720f43539c93fb075a425c0b7ba75789295b5 |
Close
Hashes for atom-0.8.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bb2b9c7f3ad9a455d23a93e54ce536bfaf0483734c94353fa1c214eed47dc47 |
|
MD5 | 499ea1c7f207ed3cf115eec7c76d7b47 |
|
BLAKE2b-256 | 8137ad5cba87345548a754713caa86c2ad55f8ed3c33abfd1a7289ee5a52363c |
Close
Hashes for atom-0.8.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cbc1ff992a5e7c167ad40f062de2e15182df59bc914e224d490ee5941a36e13 |
|
MD5 | 1e6def6948391ae00a498bf530bcf270 |
|
BLAKE2b-256 | 38686635638e37eb02fd1b5f0e315410afcdb4184e655c7e67dbc95b4ec6eb34 |
Close
Hashes for atom-0.8.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ecfb3da01d35b72a2a47fcd6302c0814f93e68659376b032ec3fd772de6cb69 |
|
MD5 | cd8f9d8350e09b802770676a1e82550c |
|
BLAKE2b-256 | 77e963b5d0275430fa86ef5057043a9555d7d1c95e9e4741a33dc1a4f6016085 |
Close
Hashes for atom-0.8.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77f4d4f1d66b8419613999b20807ab918779d5d158cc758ee41bf24ed4bf94d1 |
|
MD5 | ec638df638a72a0d1dd5efe6b1e32dc9 |
|
BLAKE2b-256 | 7109ecff743f7fd10bb7fb1926a5389d627a6bd78f6363300110615d88a95693 |
Close
Hashes for atom-0.8.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec1065f27cd07dd09134ed3892d51c4f5447dd8b8637eeb37c4f67e3c1996f5b |
|
MD5 | f276a32528611ae2772d3dfafca0366b |
|
BLAKE2b-256 | b60b152dc34eb0a5b885f64a51c1ee30feada51c9890db00dbfd4bcc7f649c20 |
Close
Hashes for atom-0.8.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6c644730ea5823d35833cbd9fb580a134eac1e7c0df1943be3afcb9163dfbb0 |
|
MD5 | d1dde1014a347fceab9d22545fda21b1 |
|
BLAKE2b-256 | aaf936837c3116ffa37974a56486bc24985af42776c0a7161bb6a1b15b63c88a |
Close
Hashes for atom-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03826332f96556d51ee2c7066ae2b4b85920facd0ae7ea19ba79b09dee41b34b |
|
MD5 | 48e63503e622566452dbeb62074a8fe0 |
|
BLAKE2b-256 | c1ca01cf12b5e987d928943c30806a75f32401947efd507924b419338c30d16b |
Close
Hashes for atom-0.8.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e0edad4c3ba4adde7efd226b0870ce34268fb17c55a990eef80336d3d2a9cf6 |
|
MD5 | 3e46e8aa72aa7526933640e67728e552 |
|
BLAKE2b-256 | 1639201ea990350217ee72d5528f25acb1f5ac08f07d249adfa2a708ce9eba30 |
Close
Hashes for atom-0.8.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff23c8e8cdded69258e76227efaf8965ccfe11a09a308514b0e7358878d24f33 |
|
MD5 | fc010e76e6f70f2ae86ffaa04ab4fbc2 |
|
BLAKE2b-256 | 8256845416a5397a885de20293c739fdb5947dc3797cf022dc0e74146479672b |
Close
Hashes for atom-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afa450bf5cc07f68e3e51833f862cff16a0e7e75cc6d8e311ed113c57c49dfc5 |
|
MD5 | 6950dcca026522d034d6e2e7980c2c99 |
|
BLAKE2b-256 | 4ef916ccca4c799d67787153196d476d39d558d8e276e3f497a8dd5195cf3f20 |
Close
Hashes for atom-0.8.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b43f2125ce4d45c00c86413e036067cfc1968b3963be218d333b6746ddaf550 |
|
MD5 | b756fae7e46dc20a05cd710e70f9dab3 |
|
BLAKE2b-256 | b507c91b1663af693a729f66364b14daca84b7c3cd3d08e0009613ea505c06e2 |
Close
Hashes for atom-0.8.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08528132d45808c6f3b115338437b6f6888a40858c74538274c63d071ca15e48 |
|
MD5 | da63ff2d04d9ca99db2688d962d3ab85 |
|
BLAKE2b-256 | 7b51ffa7cd1940901cccd8921d46f67207acc5d43ad9a9f70e78fe15accea187 |
Close
Hashes for atom-0.8.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8acdae3ff5aa0b0d2ff5d46c6b599ac9eca12d070610893a56433a15b2ae0da0 |
|
MD5 | 538f71520c61e440b40dcf0bf935f204 |
|
BLAKE2b-256 | 71ab39fd623344f066289b6b47cf6e8ac98683e9a3c6187afe71ff9f18bd263a |
Close
Hashes for atom-0.8.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb13ebe6db358032190723df631e2a66aebc289a3802dd7f7259cda6aaa41bd4 |
|
MD5 | e0fa16b10b835c6a4fce41125ef73352 |
|
BLAKE2b-256 | f419f23278838025a3d1772736ee786f9f65e96e82d6b1e3ad1a950c5305d681 |
Close
Hashes for atom-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a19688a7ad7408769b8476e2332bb96cad5402bf28ec2022c530f7a7d04c584e |
|
MD5 | 35aab30f1dceed03c1ab653400b77dc9 |
|
BLAKE2b-256 | 9e61542acb7d1445655ba42dded90ff0ae92e33ae73c1cc49096f7e6cd380c5e |
Close
Hashes for atom-0.8.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd9d965d3a82c8ae7e11a69ce0d6ddcc0da135a5a56e633925f757c9f94f51e9 |
|
MD5 | 7f7c997ec8bdc7a243751f4407d19b45 |
|
BLAKE2b-256 | 9e800d99a627ccc5b60a59b032dbd8631d602bab8906f8ed9823d9e8fd643233 |
Close
Hashes for atom-0.8.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61439f2c35ce1e3f25376b2761e2e5432e28c0f24f3cf3219ac1fe0c48ecf80b |
|
MD5 | c24862fa8cfdab75ec09b7e2c35b8670 |
|
BLAKE2b-256 | 5b19c4810df26b0db32caf5d24113c3d0713c0f755dac5b4f0b1c3d83f5fdbcd |
Close
Hashes for atom-0.8.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cf835bfca73a6f66e57317d65ec5f187b6cebc628383adf89b14c92f3c03fe3 |
|
MD5 | 20850b8edf67403f981aba0874e52a1a |
|
BLAKE2b-256 | 81d6f590cd02b67979b4f24e9fad0b3ee16c875b44f0017f8fd6560d37a9589d |
Close
Hashes for atom-0.8.0-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c7899e97eeb572981750f1ec47afa6f09352a392d494f771523f076de987080 |
|
MD5 | 0f268e9861b8d7dec7b62ea073806033 |
|
BLAKE2b-256 | 3e3804ffe2129571b2a4711776e1905d3c11854a27bac7df27cf8ea084de9430 |