.. image:: https://secure.travis-ci.org/mulkieran/justbytes.png?branch=master
:target: http://travis-ci.org/mulkieran/justbytes
Justbytes
=========
Justbytes is a module for handling computation with
address ranges expressed in bytes. Its principle feature is a Range class from
which can be constructed Range objects which represent a precise and finite
address range in bytes. Various arithmetic operations are defined for Range
objects.
Its sole purpose is the representation of real address ranges on real
machines. For that reason, it does not allow powers of ranges, imprecise
ranges, or non-finite ranges. In order that the
usual laws of arithmetic can be maintained, it does allow fractional ranges.
Practical Computing with Address Ranges
---------------------------------------
When computing with address ranges, the numeric value can be viewed as a
logical, rather than a physical, quantity. That is, unlike, e.g., mass or
length, which are quantities which must be measured with a measuring instrument
which has some built-in imprecision, an address range
is a quantity that is not measured, but is known precisely.
This precision arises because the number represents not as much an amount of
memory as a number of addressable, byte-size, locations in memory.
Consequently, computations such as addition of two Ranges, and conversion
between different magnitudes of bytes, i.e., from MiB to GiB, must be done
precisely. The underlying implementation must therefore use a precise
representation of the number of bytes. Floating point numbers, which are
frequently the preferred type for the representation of physical
quantities, are disallowed by this requirement.
Operations
----------
This module does not accomodate multi-dimensionality of address ranges.
Consequently, multiplying one Range object by another Range object will cause
an error to be raised, since bytes^2 is not representable by the module.
For most uses any operation which would yield a multi-dimensional quantity
is not useful. There are no plans to adapt this package so that it
can accomodate multi-dimensionality of address ranges.
Numerous computations with address ranges are nonsensical. For example, 2
raised to a power which is some address range, is a meaningless computation.
All such operations cause an error to be raised.
Some computations with precise, finite, values may yield irrational results.
For example, while 2 is rational, its square root is an irrational number.
There is no allowed operation on Range objects which can result in an
irrational Range value. It turns out that all such operations are either
nonsensical or would result in a value with an unrepresentable type.
The result type of operations is a Range, where appropriate, or a subtype of
Rational, where a numeric value is appropriate.
Floating Point Numbers
----------------------
It is not possible to use floating point numbers or Decimal in computations
with Ranges. Where a fractional quantity is desired, use Fraction objects.
Thus, Range(0) * 1.2 and Range(0) * Decimal("1.2") raise an exception, but
Range(0) * Fraction("1.2") is acceptable.
Computing the Representation of a Range
---------------------------------------
The representation of a Range is computed according to a specified
configuration. In the default configuration, the representation uses IEC
rather than SI units.
The representation of a Range is not a string, but a structured representation
of the precise value, as well as the relationship of the representation to
the actual value.
This representation is exposed to clients of the library, which may use it
in any way.
Displaying Ranges
-----------------
The Range class also has standard methods for the representation of Range
objects as str objects.
The str representation can also be configured. The manipulation of the
representation to form a str object is abstracted from the rest of the source
to emphasize that clients of the package may choose to represent address ranges
in any manner they choose.
Representing Units
------------------
The size module supplies a set of named prefixes for both SI and binary units,
for all non-fractional prefixes. Fractional prefixes are not defined.
Constructing Ranges Programatically
-----------------------------------
New Range objects can be constructed from Range objects, numeric values, e.g.,
int or Fraction, or strings which represent such numeric values.
strings may be used to represent fractional quantities, e.g., "1.2", but
floats and Decimals are disallowed.
The constructor takes an optional units specifier, which defaults to bytes
for all numeric values, and to None for Range objects. The type of the
unit specifier is a named prefix supplied by the size module or a Range object.
Errors
------
All errors raised by justbytes operations are subtypes of the RangeError class.
Memory Consumption and Bandwidth vs. Address Ranges
---------------------------------------------------
Memory consumption, e.g., by a process during execution on a specified
workload, is a quantity, that like address ranges, is specified in
bytes. However, memory consumption is simply a measurement of the amount of
a phsyical quantity consumed. When bytes are used only to represent memory
consumption, computations do not generally require the special handling
supplied by this library. Generally, measurement of memory consumption can
be treated like any other physical quantity. The same reasoning applies to
bandwidth. For a physical analogy, one can imagine memory consumption to be
analogous to volume, e.g., litres, and bandwidth to be analogous to flow,
e.g., litres per minute.
User Input
----------
This package does not handle arbitrary user input. It is expected that the
client will transform any input, from whatever source, into a number and an
optional unit specification which can be passed directly to the Range
constructor.
Alternative Packages
--------------------
If you are interested in computing in Python with physical, rather than
logical, quantities, you should consult the pint package:
http://pint.readthedocs.org.
Packaging
---------
Downstream packagers, if incorporating testing into their packaging, are
encouraged to use only the tests in the test_deterministic module, to
avoid testing failures that may arise due to the non-deterministic behavior
of Hypothesis tests.
Raw data
{
"_id": null,
"home_page": "https://github.com/mulkieran/justbytes",
"name": "justbytes",
"maintainer": "",
"docs_url": "https://pythonhosted.org/justbytes/",
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Anne Mulhern",
"author_email": "amulhern@redhat.com",
"download_url": "https://files.pythonhosted.org/packages/df/07/fff1ce44b8927425f72a132f5757aa55dfdc2d9bb4c50bdd803b54edb4c9/justbytes-0.15.2.tar.gz",
"platform": "Linux",
"description": ".. image:: https://secure.travis-ci.org/mulkieran/justbytes.png?branch=master\n :target: http://travis-ci.org/mulkieran/justbytes\n\nJustbytes\n=========\n\nJustbytes is a module for handling computation with\naddress ranges expressed in bytes. Its principle feature is a Range class from\nwhich can be constructed Range objects which represent a precise and finite\naddress range in bytes. Various arithmetic operations are defined for Range\nobjects.\n\nIts sole purpose is the representation of real address ranges on real\nmachines. For that reason, it does not allow powers of ranges, imprecise\nranges, or non-finite ranges. In order that the\nusual laws of arithmetic can be maintained, it does allow fractional ranges.\n\n\nPractical Computing with Address Ranges\n---------------------------------------\n\nWhen computing with address ranges, the numeric value can be viewed as a\nlogical, rather than a physical, quantity. That is, unlike, e.g., mass or\nlength, which are quantities which must be measured with a measuring instrument\nwhich has some built-in imprecision, an address range\nis a quantity that is not measured, but is known precisely.\nThis precision arises because the number represents not as much an amount of\nmemory as a number of addressable, byte-size, locations in memory.\n\nConsequently, computations such as addition of two Ranges, and conversion\nbetween different magnitudes of bytes, i.e., from MiB to GiB, must be done\nprecisely. The underlying implementation must therefore use a precise\nrepresentation of the number of bytes. Floating point numbers, which are\nfrequently the preferred type for the representation of physical\nquantities, are disallowed by this requirement.\n\nOperations\n----------\nThis module does not accomodate multi-dimensionality of address ranges.\nConsequently, multiplying one Range object by another Range object will cause\nan error to be raised, since bytes^2 is not representable by the module.\nFor most uses any operation which would yield a multi-dimensional quantity\nis not useful. There are no plans to adapt this package so that it\ncan accomodate multi-dimensionality of address ranges.\n\nNumerous computations with address ranges are nonsensical. For example, 2\nraised to a power which is some address range, is a meaningless computation.\nAll such operations cause an error to be raised.\n\nSome computations with precise, finite, values may yield irrational results.\nFor example, while 2 is rational, its square root is an irrational number.\nThere is no allowed operation on Range objects which can result in an\nirrational Range value. It turns out that all such operations are either\nnonsensical or would result in a value with an unrepresentable type.\n\nThe result type of operations is a Range, where appropriate, or a subtype of\nRational, where a numeric value is appropriate.\n\nFloating Point Numbers\n----------------------\nIt is not possible to use floating point numbers or Decimal in computations\nwith Ranges. Where a fractional quantity is desired, use Fraction objects.\nThus, Range(0) * 1.2 and Range(0) * Decimal(\"1.2\") raise an exception, but\nRange(0) * Fraction(\"1.2\") is acceptable.\n\nComputing the Representation of a Range\n---------------------------------------\nThe representation of a Range is computed according to a specified\nconfiguration. In the default configuration, the representation uses IEC\nrather than SI units.\n\nThe representation of a Range is not a string, but a structured representation\nof the precise value, as well as the relationship of the representation to\nthe actual value.\n\nThis representation is exposed to clients of the library, which may use it\nin any way.\n\nDisplaying Ranges\n-----------------\nThe Range class also has standard methods for the representation of Range\nobjects as str objects.\n\nThe str representation can also be configured. The manipulation of the\nrepresentation to form a str object is abstracted from the rest of the source\nto emphasize that clients of the package may choose to represent address ranges\nin any manner they choose.\n\nRepresenting Units\n------------------\nThe size module supplies a set of named prefixes for both SI and binary units,\nfor all non-fractional prefixes. Fractional prefixes are not defined.\n\nConstructing Ranges Programatically\n-----------------------------------\nNew Range objects can be constructed from Range objects, numeric values, e.g.,\nint or Fraction, or strings which represent such numeric values.\nstrings may be used to represent fractional quantities, e.g., \"1.2\", but\nfloats and Decimals are disallowed.\n\nThe constructor takes an optional units specifier, which defaults to bytes\nfor all numeric values, and to None for Range objects. The type of the\nunit specifier is a named prefix supplied by the size module or a Range object.\n\nErrors\n------\nAll errors raised by justbytes operations are subtypes of the RangeError class.\n\nMemory Consumption and Bandwidth vs. Address Ranges\n---------------------------------------------------\nMemory consumption, e.g., by a process during execution on a specified\nworkload, is a quantity, that like address ranges, is specified in\nbytes. However, memory consumption is simply a measurement of the amount of\na phsyical quantity consumed. When bytes are used only to represent memory\nconsumption, computations do not generally require the special handling\nsupplied by this library. Generally, measurement of memory consumption can\nbe treated like any other physical quantity. The same reasoning applies to\nbandwidth. For a physical analogy, one can imagine memory consumption to be\nanalogous to volume, e.g., litres, and bandwidth to be analogous to flow,\ne.g., litres per minute.\n\nUser Input\n----------\nThis package does not handle arbitrary user input. It is expected that the\nclient will transform any input, from whatever source, into a number and an\noptional unit specification which can be passed directly to the Range\nconstructor.\n\nAlternative Packages\n--------------------\nIf you are interested in computing in Python with physical, rather than\nlogical, quantities, you should consult the pint package:\nhttp://pint.readthedocs.org.\n\nPackaging\n---------\nDownstream packagers, if incorporating testing into their packaging, are\nencouraged to use only the tests in the test_deterministic module, to\navoid testing failures that may arise due to the non-deterministic behavior\nof Hypothesis tests.\n",
"bugtrack_url": null,
"license": "LGPL-2.1-or-later",
"summary": "\"computing with and displaying bytes\"",
"version": "0.15.2",
"project_urls": {
"Homepage": "https://github.com/mulkieran/justbytes"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f6f59d5eff566f8a97442629a8ab075be10db4247845c5a78085be3e348d0d22",
"md5": "a1d1d2e9dcad316a9df189e7e22eb8a5",
"sha256": "83df43b57aa764c9eb65f01fc2af623cf11523153340db70fde1fbbd715536f6"
},
"downloads": -1,
"filename": "justbytes-0.15.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a1d1d2e9dcad316a9df189e7e22eb8a5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 27241,
"upload_time": "2023-05-15T20:43:06",
"upload_time_iso_8601": "2023-05-15T20:43:06.420617Z",
"url": "https://files.pythonhosted.org/packages/f6/f5/9d5eff566f8a97442629a8ab075be10db4247845c5a78085be3e348d0d22/justbytes-0.15.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "df07fff1ce44b8927425f72a132f5757aa55dfdc2d9bb4c50bdd803b54edb4c9",
"md5": "76d08a706419d6f6f72de9a47c660339",
"sha256": "c4cbeefc383014508933f03a47100dd22f4b01ac83f4fa204e13144a80c1cbcc"
},
"downloads": -1,
"filename": "justbytes-0.15.2.tar.gz",
"has_sig": false,
"md5_digest": "76d08a706419d6f6f72de9a47c660339",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 24501,
"upload_time": "2023-05-15T20:43:07",
"upload_time_iso_8601": "2023-05-15T20:43:07.925348Z",
"url": "https://files.pythonhosted.org/packages/df/07/fff1ce44b8927425f72a132f5757aa55dfdc2d9bb4c50bdd803b54edb4c9/justbytes-0.15.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-15 20:43:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mulkieran",
"github_project": "justbytes",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "justbytes"
}