<commit_before>Scheme S-expressions
====================

This is a serializer that produces an S-expression compatible with a
subset of R7RS Scheme.

Basic usage::

  import ssexp
  ssexp.dump({'brian': 'naughty boy'})

produces:

.. code-block:: scheme

   (: brian: "naughty boy")

We use the ``preserialize`` library to pre-serialize more complex
structures, and so can handle shared objects, cyclic references and
deep structures::

   class Parrot(object):
       def __init__(self, is_dead=True, from_egg=None):
           self.is_dead = is_dead
           self.from_egg = from_egg

   preserializer = ssexp.SsexpPreserializer()
   preserializer.register(Parrot, version=2)

   class Egg(object):
       def __init__(self, from_parrot=None):
           self.from_parrot = from_parrot

   preserializer.register(Egg)

   parrot = Parrot()
   parrot.from_egg = Egg(from_parrot=parrot)

   ssexp.dumps({'brian': 'naughty boy',
                3: 'Antioch',
		'ouroboros': parrot}, preserializer)

produces:

.. code-block:: scheme
<commit_msg>Fix typo and mark Python code blocks.<commit_after>Scheme S-expressions
====================

This is a serializer that produces an S-expression compatible with a
subset of R7RS Scheme.

Basic usage:

.. code-block:: python

  import ssexp
  ssexp.dumps({'brian': 'naughty boy'})

produces:

.. code-block:: scheme

   (: brian: "naughty boy")

We use the ``preserialize`` library to pre-serialize more complex
structures, and so can handle shared objects, cyclic references and
deep structures:

.. code-block:: python

class Parrot(object):
       def __init__(self, is_dead=True, from_egg=None):
           self.is_dead = is_dead
           self.from_egg = from_egg

   preserializer = ssexp.SsexpPreserializer()
   preserializer.register(Parrot, version=2)

   class Egg(object):
       def __init__(self, from_parrot=None):
           self.from_parrot = from_parrot

   preserializer.register(Egg)

   parrot = Parrot()
   parrot.from_egg = Egg(from_parrot=parrot)

   ssexp.dumps({'brian': 'naughty boy',
                3: 'Antioch',
		'ouroboros': parrot}, preserializer)

produces:

.. code-block:: scheme

{'fraction_non_alphanumeric': 0.12257169287696577, 'fraction_numerical': 0.0027752081406105457, 'mean_word_length': 3.553684210526316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5575262', 'n_tokens_mistral': 742, 'n_tokens_neox': 702, 'n_words': 186}