Skip to main content
https://github.com/Phynix/yamlloader/actions/workflows/ci.yml/badge.svg https://img.shields.io/pypi/pyversions/yamlloader.svg https://badge.fury.io/py/yamlloader.svg https://coveralls.io/repos/github/Phynix/yamlloader/badge.svg

yamlloader

This module provides loaders and dumpers for PyYAML. Currently, an OrderedDict loader/dumper is implemented, allowing to keep items order when loading resp. dumping a file from/to an OrderedDict (Python 3.8+: Also regular dicts are supported and are the default items to be loaded to. As of Python 3.7 preservation of insertion order is a language feature of regular dicts.)

This project was originally mirrored from yamlordereddict Many thanks to the original author François Ménabé! The library contains several improvements including automated testing and the much faster C-versions of the Loaders/Dumpers.

API Documentation

Install

There is a pip and a conda version available

$ pip install yamlloader

or

$ conda install yamlloader -c conda-forge

But does [your special case here] also work?

Tests are run continuously using randomly generated yaml files. Also, there are no fails to be expected.

Still, if you are concerned that your special case may breaks in the future, please add your own tests as test_ext_anyname.py under tests/ or let us know about your needs. This guarantees that no code will be added that breaks your case.

C vs non-C version

A significant speedup can be reached by replacing the Loader* and Dumper* classes by CLoader* and CDumper*. The package hereby relies on the implementations from PyYAML. If they have not been compiled, yamlloader automatically falls back to the non-C versions.

Therefore using the C-version is safe: if it is not available, the pure Python version is automatically used.

Usage examples

Loader usage

import yaml
import yamlloader

with open('myfile.yml') as yaml_file:
    data = yaml.load(yaml_file,
                     Loader=yamlloader.ordereddict.CLoader)
                     # CLoader is faster than Loader

Note: For using the safe loader (which takes standard YAML tags and does not construct arbitrary Python objects), replace yamlloader.ordereddict.CLoader by yamlloader.ordereddict.CSafeLoader.

Dumper usage

import yaml
import yamlloader
from collections import OrderedDict

data = OrderedDict([('key1', 'val1'),
                    ('key2', OrderedDict([('key21', 'val21'),
                                          ('key22', 'val22')]))])

with open('myfile.yaml', 'w') as yaml_file:
    yaml.dump(data, yaml_file,
              Dumper=yamlloader.ordereddict.CDumper)

Note: For using the safe dumper (which produce standard YAML tags and does not represent arbitrary Python objects), replace yamlloader.ordereddict.CDumper by yamlloader.ordereddict.CSafeDumper.

FAQ

C version not working

If the C version is not working (it falls back by default to a non-C version), check if yaml.cyaml exists. If not, the cyaml module was not compiled during the installation of yaml (pyyaml). Make sure that cython is installed (pip install Cython) and the yaml.h file is there (apt: libyaml-dev).

Release files for yamlloader 1.6.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 yamlloader 1.6.0
File Size Uploaded
yamlloader-1.6.0.tar.gz 77.6 kB Details

Built distribution (wheel)

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

Total release size: 85.4 kB

Release files / yamlloader-1.6.0.tar.gz

Download URL yamlloader-1.6.0.tar.gz
Size 77.6 kB
Tags Source
SHA-256 checksum
How to use checksums
918232976c9910d079ef74b3266ff9ef674228609aa56e67718b3992940a823f
BLAKE2b-256 checksum
How to use checksums
e7e681677e777ca8a3588012f74e215050e3001e39d253076beb1c3306fc9460
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2025.

Transparency log

Release files / yamlloader-1.6.0-py3-none-any.whl

Download URL yamlloader-1.6.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9ea9948759732eab65e1dbcea510f1582b9c096aab33c893bf55ae9d58783e8
BLAKE2b-256 checksum
How to use checksums
d28a132113ebc0f5ef3e893c4c75b058f70206b80a8a69ba46fbaeb5d409eb32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.3.2

2 release files

1.2.2

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.5.5

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.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