Skip to main content

metaset

This package provides a collection that is basically a “dict of sets”, named MetaSet.

Build status Supported Python versions Wheel status License

Quickstart

Install the package from PyPI, using pip:

pip install metaset

Or from GitHub:

git clone git://github.com/Polyconseil/metaset.git

Import it in your code:

>>> from metaset import MetaSet

Usage is quite straight forward, basic set operations are supported via the binary operators + - | ^.

>>> from pprint import pprint
>>> pprint(MetaSet(a={1, 2}, b={3}) | MetaSet(b={4}, c={5}))
{'a': {1, 2}, 'b': {3, 4}, 'c': {5}}

Django Postgres

A custom Django field is available. It is quite straightforward:

>>> from metaset.django_field import MetaSetField
>>> from django.db import models        # doctest: +SKIP

>>> class MyModel(models.Model):        # doctest: +SKIP
        mset = MetaSetField()           # doctest: +SKIP

The following versions of Python and Django are supported:

  • Python 2.7, 3.6, 3.7 and 3.8;

  • Django 1.11, 2.0, 2.1, 2.2, 3.0 and 3.1.

Detailed considerations

They are two ways to consider the “dict of sets” notion, differing on how you handle the empty values for keys.

The easiest idea is to consider that a key with no content is non-existent. This is how the dictset package is implemented.

In this alternative implementation, we chose to keep the empty keys as meaningful elements, allowing for smart unions and intersections.

>>> pprint(MetaSet(a={1}) | MetaSet(a={2}, b=set()))
{'a': {1, 2}, 'b': set()}

>>> MetaSet(a={1}) & MetaSet(a={2}, b={3})
{'a': set()}

So, beware of how empty-keys are handled, and consider using dictset if it is a better match for your use case. The behavior for subtraction and symmetric difference, although sound on a mathematical point of view, may not be what you want.

>>> MetaSet(a={1}) - MetaSet(a={1})
{'a': set()}

>>> MetaSet(a={1}) ^ MetaSet(a={1})
{'a': set()}

Release files for metaset 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metaset 2.0.0
File Size Uploaded
metaset-2.0.0.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metaset 2.0.0
File Interpreter ABI Platform
metaset-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size:11.0 kB

Release files / metaset-2.0.0.tar.gz

Download URL metaset-2.0.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a435189e355a009d6f584748fa45c2084902c8f6d734d5e83d66c786e7f90f00
BLAKE2b-256 checksum
How to use checksums
d4944d409dae3d4fc2d5c583265fd00bf9857a45a5afe45aba49e307102d3157
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / metaset-2.0.0-py3-none-any.whl

Download URL metaset-2.0.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
faa8f8472b92e5838ad83b63a698d01eec0b2c95c18a49ad8d26b6d369e0b1c2
BLAKE2b-256 checksum
How to use checksums
67050d7c1685aaad761aa7476eae675bcd0c86bd102ae44c292e3417945fd9a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

1 release file

1.0.2

1 release file

1.0.1

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page