Skip to content

Commit

Permalink
add FAQ entry about remap vs glom, fixes #237
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoud committed Nov 28, 2023
1 parent 278a7f0 commit f9a68b0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,31 @@ facility <glom.Inspect>`, and a compact, composable design.
In short, thanks to Python, glom can provide a Pythonic solution for
those times when pure Python wasn't Pythonic enough.

Should I use glom or remap?
---------------------------

These days, you have a lot of choices when it comes to nested data manipulation.
One choice is between glom and `remap`_, the recursive ``map()``.
Given that the same people wrote both utilties, we recommend:

* If you know the shape of the output ahead of time, then go with glom.
* If your output shape is determined by the input, then use remap.

Remap performs a full traversal of a nested data structure, walking it like a tree.
In contrast, glom only goes where it's told by the spec.

For example, imagine an error reporting service.
Users send you an arbitrary dictionary of metadata related to the error.
But you have a requirement that you don't store secrets.

Remap is a great way to traverse that full structure,
looking for all keys containing the substring "secret",
replacing the associated value with "[REDACTED]".
The output shape will be the same as the input shape.

At the time of writing (2023), glom isn't designed for this use case.

.. _remap: https://boltons.readthedocs.io/en/latest/iterutils.html#nested

How does glom work?
-------------------
Expand Down

0 comments on commit f9a68b0

Please sign in to comment.