Add utilities for counting iterables and lazily-compiling regexes.

Review Request #13160 — Created July 25, 2023 and submitted — Latest diff uploaded

Information

Djblets
release-4.x

Reviewers

This introduces djblets.util.functional, which offers two useful
functions:

  • iterable_len(): Efficiently computes the length of a finite
    iterable.

  • lazy_re_compile(): Lazily compiles a regex on first access, reducing
    module load time for regexes as class/module attributes.

Unit tests pass.

Used both of these in some in-progress code.

Diff Revision 1 (Latest)

Commits

First Last Summary ID Author
Add utilities for counting iterables and lazily-compiling regexes.
This introduces `djblets.util.functional`, which offers two useful functions: * `iterable_len()`: Efficiently computes the length of a finite iterable. * `lazy_re_compile()`: Lazily compiles a regex on first access, reducing module load time for regexes as class/module attributes.
fe7b35f3729b3bbeb7c088b6550e0f80d12fb5da Christian Hammond
djblets/util/functional.py
djblets/util/tests/test_functional.py
docs/djblets/coderef/index.rst
Loading...