Skip to main content

A list where most (>95%) values will be None (or default)

Project description

`Sparse List <https://pypi.python.org/pypi/sparse_list>`__ |PyPi version| |PyPi downloads| |Build Status|
=========================================================================================================

Inspired by the post `Populating a sparse list with random
1's <http://stackoverflow.com/q/17522753/78845>`__ on
`StackOverflow <http://stackoverflow.com/>`__.

A "sparse list" is a list where most (say, more than 95% of) values will
be None (or some other default) and for reasons of memory efficiency you
don't wish to store these (cf. `Sparse
array <http://en.wikipedia.org/wiki/Sparse_array>`__).

This implementation has a similar interface to Python's built-in list
but stores the data in a dictionary to conserve memory.

Installation
------------

`sparse_list <https://pypi.python.org/pypi/sparse_list>`__ is
available from `PyPI - the Python Package
Index <https://pypi.python.org/pypi>`__ (aka `The
Cheeseshop <https://pypi.python.org/pypi>`__).

Installation is simply:

::

$ pip install sparse_list

Usage
-----

See the
`unit-tests <https://github.com/johnsyweb/python_sparse_list/blob/master/t_sparse_list.py>`__!

Contributing
------------

1. Fork it
2. Create your feature branch (``git checkout -b my-new-feature``)
3. Commit your changes (``git commit -am 'Add some feature'``)
4. Ensure the tests pass for all Pythons in
`.travis.yml <https://github.com/johnsyweb/python_sparse_list/blob/master/.travis.yml>`__
5. Push to the branch (``git push origin my-new-feature``)
6. Create new Pull Request

Thanks
------

If you find this stuff useful, please follow this repository on
`GitHub <https://github.com/johnsyweb/python_sparse_list>`__. If you
have something to say, you can contact
`johnsyweb <http://johnsy.com/about/>`__ on
`Twitter <http://twitter.com/johnsyweb/>`__ and
`GitHub <https://github.com/johnsyweb/>`__.

.. |PyPi version| image:: https://pypip.in/v/sparse_list/badge.png
:target: https://crate.io/packages/sparse_list/
.. |PyPi downloads| image:: https://pypip.in/d/sparse_list/badge.png
:target: https://crate.io/packages/sparse_list/
.. |Build Status| image:: https://travis-ci.org/johnsyweb/python_sparse_list.png
:target: https://travis-ci.org/johnsyweb/python_sparse_list
--------------------------------------------------------------------------------
Copyright (c) 2013 Pete Johns

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparse_list-0.4.tar.gz (3.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page