Skip to main content

ReOBJ: Description

ReOBJ:

R(estricted) E(xtended) Objects. Simple, reasonable fast, restricted/extended python objects.

HTML Documentation

HTML documentation of the project is hosted at: ReOBJ-HTML documentation

Or Package Documentation

Main Info

ReOBJ contains different restricted/extended python objects.

  • ReDICTs: Simple, reasonable fast, restricted/extended python dictionary objects.

  • ReLISTs: Simple, reasonable fast, restricted/extended list objects.

  • ReTUPLEs: Simple, reasonable fast, restricted/extended tuple objects.

  • ReMATRIXs: Simple, reasonable fast, restricted/extended list-of-tuples objects.

All `ReBASE classes - subclasses`:

  • can be dumped with json: but will lose any extra data like: key_order (list) or/and any extra_data dict

  • can be pickled

  • additional methods:

    • set_extra_data(), update_extra_data(), replace_extra_data(): Sets/updates key/value to the additional dictionary: extra_data

    • copy_recursively(): recursively copy: Supports recursively intermediate ReDICT, ReLIST, ReTUPLE, dicts, lists and tuples (and their subclasses: depending on there implementation though)

      • this will also copy any ReDICT / ReLIST / ReTUPLE / ReMATRIX extra_data dict and any key_order (list) and any extra_key_order (list)

    • copy_recursively_to_python_native_types(): recursively copy: changing all ReOBJ to native python types.

      • RdictIO, RdictFO, RdictFO2: to python `OrderedDict obj keeping their order (see also argument: use_extra_key_order)

      • all other ReDICT: objects will be replaced by normal python dict objs

      • all ReLIST obj will be replaced by normal python list objs

      • all ReTUPLE obj will be replaced by normal python tuple objs

      • all ReMATRIX obj will be replaced by normal python list of tuple objs

      Supports recursively intermediate ReDICT, ReLIST, ReTUPLE, dicts, lists and tuples (and their subclasses: depending on there implementation though)

    • topickle(): returns a new pickled dumps byte string from the obj

    • tojson(): returns a new json dumps string from the obj

    • tojson_keeporder(): returns a new json dumps string from the obj keeping the order of any RdictIO, RdictFO, RdictFO2

      • this uses first the: copy_recursively_to_python_native_types()

ReDICT

Overview Differences

  • Edict is similar to a normal python dict but has some additional (extended) features

  • Rdict and RdictIO: can add new items after creation/initialization

  • RdictF and RdictFO, RdictFO2: F(ix) can not add new items after creation/initialization

  • Rdict and RdictF: do not have any key_order (list) nor any extra_key_order (list)

  • RdictIO and RdictFO, RdictFO2: O(rder) do have a key_order (list) plus an extra_key_order (list)

    • RdictIO: I(nsertion) O(rder): keeps track of the order new keys where added

    • RdictFO, RdictFO2: F(ix) O(rder): keeps track of the order of the keys when it was created/initialized

    • all three have the extra_key_order (list):
      • this is a list which can be optionally set with a user defined key order (can also include just a subset of keys)

    • all three can be converted to OrderedDict: keeping their key_order or optionally the extra_key_order

      • example usage to print an ordered json using the method: tojson_keeporder()

      example_rdictordered = RdictFO([
         ('key1', 'value1'),
         ('key2', 'value2'),
         ('key3', RdictIO([
            ('inner_key1', 'innervalue1'),
            ('inner_key2', 'innervalue2'),
         ], False)),
      ], False)
      
      json_dumps = example_rdictordered.tojson_keeporder(indent=3)
      print(json_dumps)

      Output will be:

      {
         "key1": "value1",
         "key2": "value2",
         "key3": {
            "inner_key1": "innervalue1",
            "inner_key2": "innervalue2"
         }
      }
    • RdictFO vs. RdictFO2: RdictFO can change the values. RdictFO2 can after creation not change the values

ReLIST

  • Elist is similar to a normal python list but has some additional (extended) features

  • Rlist: can add new items after creation/initialization

  • RlistF: F(ix) can not add new items after creation/initialization

ReTUPLE

  • Etuple is similar to a normal python tuple but has some additional (extended) features

ReMATRIX

  • Lmatrix is a List-Of-Tuples with some additional (extended) features

  • LmatrixF: F(ix) can not add new items (tuple-rows) after creation/initialization

Code Examples

for code examples see the files in ‘development source` folders: Examples, Tests, SpeedCheck

Projects using ReOBJ

projects which make use of: ReOBJ



ReOBJ is distributed under the terms of the BSD 3-clause license. Consult LICENSE.rst or http://opensource.org/licenses/BSD-3-Clause.

(c) 2014, peter1000 https://github.com/peter1000 All rights reserved.



Release files for ReOBJ 1.1.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 ReOBJ 1.1.0
File Size Uploaded
ReOBJ-1.1.0.tar.bz2 12.4 kB Details

Release files / ReOBJ-1.1.0.tar.bz2

Download URL ReOBJ-1.1.0.tar.bz2
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
352cb66179d116e69fe67bd3f386098cd5b2554cae7650011ae8798297dbca35
BLAKE2b-256 checksum
How to use checksums
efd0469748ead9dfb5dfc9f3f440ed7d6997b278acd633ae1fa6700fe04411d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1.0 This release

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