https://github.com/moreati/oprint
A pprint for CPython 3.6 dict objects that preserves insertion order
https://github.com/moreati/oprint
Last synced: 7 months ago
JSON representation
A pprint for CPython 3.6 dict objects that preserves insertion order
- Host: GitHub
- URL: https://github.com/moreati/oprint
- Owner: moreati
- Created: 2017-05-15T22:58:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-15T23:12:30.000Z (over 8 years ago)
- Last Synced: 2025-03-18T07:47:40.948Z (7 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
======
oprint
======.. image:: https://travis-ci.org/moreati/oprint.svg?branch=master
:target: https://travis-ci.org/moreati/oprint
:alt: Build TestsA ``pprint`` for CPython 3.6 ``dict`` objects that preserves insertion order.
About
=====CPython 3.6 uses a new "compact" representation for `dict`_ objects. As a
nice side effect this happens to preserve the insertion order of keys.The order-preserving aspect of this new implementation is considered an
implementation detail and should not be relied upon``pprint.pprint()`` retains it's behaviour from earlier Python releases.
It formats a ``dict`` object by sorting the keys alphabetically... code:: python
>>> import pprint
>>> pprint.pprint({'foo': 1, 'bar': 2, 'baz': 3})
{'bar': 2, 'baz': 3, 'foo': 1}``oprint.pprint()`` throws out the old.
.. code:: python
>>> import oprint
>>> oprint.pprint({'foo': 1, 'bar': 2, 'baz': 3})
{'foo': 1, 'bar': 2, 'baz': 3}The library is otherwise a drop-in replacement for ``pprint``.
Install
=======.. code:: sh
pip install oprint
Development
===========This project is developed on `GitHub`_, please file `issues`_ for any feature
or bug requests.Contributors
============- `Alex Willmer`_
.. _pprint.pprint(): https://docs.python.org/3.6/library/pprint.html
.. _dict: https://docs.python.org/3.6/whatsnew/3.6.html#whatsnew36-compactdict
.. _GitHub: https://github.com/moreati/oprint
.. _issues: https://github.com/moreati/oprint/issues
.. _Alex Willmer: https://github.com/moreati