# Compatibility

`textfsm2` matches [google/textfsm](<https://github.com/google/textfsm>)'s main branch with two intentional design choices: how the package is named and how non-participating capture groups behave by default.

## Package layout (`httpx2` model)

`textfsm2` installs under the module name `textfsm2` rather than overwriting `textfsm` in `site-packages`. This lets tools and libraries that declare a dependency on `textfsm` (such as `ntc-templates` and `netmiko`) coexist in the same environment with standard dependency resolution. Applications can switch explicitly with `import textfsm2 as textfsm` or redirect third-party `import textfsm` calls process-wide via `textfsm2.alias_textfsm()`.

## Non-participating alternation groups (\#151)

[google/textfsm\#151](<https://github.com/google/textfsm/pull/151>) on upstream's unreleased main branch stopped assigning `None` to a `Value` whose named group sits in an alternation branch that did not match. That change is unreleased and breaks 28 `ntc-templates` tests.

`textfsm2` keeps the released **textfsm 2.1.1** behaviour by default so existing templates continue to pass unmodified. You can opt in to the new behaviour via `SKIP_NONPARTICIPATING_GROUPS` or `TEXTFSM_SKIP_NONPARTICIPATING_GROUPS=1` (see [Configure cache and compatibility](<https://ryanmerolle.github.io/textfsm2/guides/configuration/index.md>)). With it enabled, upstream `textfsm`'s own test suite passes 113/113 unmodified.

## Post-2.1.1 fixes included

Other post-2.1.1 bug fixes on `google/textfsm`'s main branch are included out of the box:

- **\#149:** Backslashes in `Value` names raise `TextFSMTemplateError` instead of failing later in `re.sub` or building a mangled template.
- **\#152:** `LabelValueTable`'s default label behaviour is fixed.
- **\#153:** The `textfsm2 --help` CLI entrypoint prints help cleanly instead of crashing.

## Free-threaded Python

TextFSM2 supports free-threaded CPython (3.14t, 3.15t). Releases include `cp314t` and `cp315t` wheels next to the abi3 wheel, the extension declares that it does not need the GIL, and every pull request runs the test suite on 3.15t under [gilguard](<https://github.com/mikeckennedy/gilguard>), which fails if any import turns the GIL back on.

Thread safety is tested directly: `tests/test_free_threading.py` parses the same inputs from many threads, through `TextFSM` and through ntc-templates `parse_output`, and requires results identical to a sequential run.

The goal is that free-threaded Python is never slower than the standard build. Pull requests report the comparison in their impact comment, and each release publishes it in the [benchmarks](<https://ryanmerolle.github.io/textfsm2/reference/benchmarks/index.md#free-threaded-python>).

## Differential verification

Every change is verified against:

- Upstream [google/textfsm](<https://github.com/google/textfsm>)'s test suite.
- All 7,810 tests in [ntc-templates](<https://github.com/networktocode/ntc-templates>).
- Randomized differential testing (`tests/differential.py`) comparing outputs, exceptions, and internal FSM state against upstream `textfsm` across valid, foreign, non-ASCII, and fuzzed broken templates.
