Debian Codegraph @

docs/topics/public-vs-internal.md

raw symbols SCIP
1 # Public vs internal API
2
3 You can import anything from the `libtmux` namespace and build on it: those
4 names are the public API — documented, and changed only through a deprecation
5 process announced ahead of time. (libtmux is pre-1.0, so a minor version can
6 still carry a breaking change; pin a version when you need to lock things
7 down.) See the {doc}`public API reference </project/public-api>` for the
8 stability policy. Anything with a
9 leading underscore in its module path — `libtmux._internal.*`,
10 `libtmux._vendor.*` — is implementation detail that can change without warning.
11 If you only reach for the public API, that's the whole story, and you can stop
12 reading here.
13
14 ## The boundary
15
16 The rule is mechanical: if you can import a name without a leading underscore
17 anywhere in its module path, it's public. The table maps each import prefix to
18 exactly what you can count on.
19
20 | Import path | Status | Stability |
21 |-------------|--------|-----------|
22 | `libtmux.*` | Public | Covered by [deprecation policy](../project/public-api.md) |
23 | `libtmux._internal.*` | Internal | No guarantee — may break between any release |
24 | `libtmux._vendor.*` | Vendored | Not part of the API at all |
25
26 The authoritative list of what's stable lives in
27 {doc}`Public API </project/public-api>`.
28
29 ## Why the split
30
31 Staying on the public API buys you a predictable migration path: when a public
32 name changes, it goes through a deprecation process first — a warning for at
33 least one release, documented in the changelog — rather than vanishing without
34 notice. (libtmux is pre-1.0, so a minor version can still carry a breaking
35 change; pin a version when you need to lock things down.) Reaching into an
36 internal module buys you none of that — a refactor of
37 {mod}`~libtmux._internal.query_list` ships with no deprecation cycle, so an import
38 that works today can break on the very next release. That freedom is the point: internal modules let the library iterate on
39 implementation details without dragging downstream users through a migration for
40 each one.
41
42 The same line keeps the public surface intentionally small. Every public module
43 is a commitment to maintain, so internal modules earn promotion only through
44 proven stability and real user demand.
45
46 ## What `_internal/` contains
47
48 The `_internal/` package holds the machinery the public objects run on —
49 implementation details you never need to understand to use libtmux:
50
51 - {mod}`~libtmux._internal.query_list` — the filtering engine behind
52 {meth}`.filter() <libtmux._internal.query_list.QueryList.filter>` and
53 {meth}`.get() <libtmux._internal.query_list.QueryList.get>` on collections
54 - {mod}`~libtmux._internal.dataclasses` — base dataclass utilities used by the ORM objects
55 - {mod}`~libtmux._internal.constants` — internal constants not meaningful to end users
56 - {mod}`~libtmux._internal.sparse_array` — the sparse-index mapping behind indexed hooks and options
57
58 These are documented in {ref}`internals` for contributors, but downstream
59 projects should not import from them.
60
61 ## What `_vendor/` contains
62
63 The `_vendor/` package holds vendored third-party code — copies of external
64 libraries bundled directly so libtmux can avoid adding dependencies. You're not
65 meant to import from it; it isn't written by the libtmux authors and isn't part
66 of the API.
67
68 ## How internal APIs get promoted
69
70 Most readers never need this section — it's for contributors and for anyone
71 tempted to depend on an internal name. An API travels three stages on its way to
72 the public contract:
73
74 1. **Internal**: lives in `_internal/`, no stability promise
75 2. **Experimental**: documented, usable, but explicitly marked as subject to change
76 3. **Public**: moved to a top-level module, covered by the deprecation policy
77
78 Promotion happens when an internal API proves stable across multiple releases and
79 users ask for it. If you depend on an internal API, [file an
80 issue](https://github.com/tmux-python/libtmux/issues) — that signal helps
81 prioritize promotion.
82
83 Once a name is public and later has to change, it doesn't vanish quietly; it
84 moves through {doc}`a deprecation cycle </project/deprecations>` first. For the
85 platforms and tmux versions that stability is promised against, see
86 {doc}`Compatibility </project/compatibility>`.