cwcwidth
Python bindings for wc(s)width
Decision gist · record as of 2026-08-14
Yes, if you need fast Unicode display-width calculations for terminal output. The library is actively maintained, has no security vulnerabilities, carries a permissive license, and offers substantial performance gains over pure-Python alternatives. Install friction is moderate but manageable with prebuilt wheels for all major platforms. Requires Python 3.11+.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.11 or later.
- Medium install friction due to compiled wheels, but well-supported across platforms (macOS arm64/x86_64, Linux x86_64/aarch64, Windows 32/64-bit, musl).
- Active maintenance with recent release.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute cwcwidth freely with minimal restrictions.
last release 2025-11-01 (286 days) · last repo commit 2026-07-24 · 8 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 575,923 downloads/mo, #5,933 on PyPI
Alternatives
Verify before relying
pip install cwcwidth
import cwcwidth
print(cwcwidth.wcwidth('a')) # 1
print(cwcwidth.wcswidth('コンニチハ, セカイ!')) # 19- Whether performance improvement over wcwidth remains significant in real-world terminal applications beyond the benchmark shown.
- Whether the limited Python API mode (via USE_LIMITED_API environment variable) affects performance or compatibility.
What it is and what it does
cwcwidth is a C-based Python library that calculates how many columns a Unicode string will occupy when displayed in a terminal. It wraps POSIX wcwidth/wcswidth functions (or Markus Kuhn's implementation on non-POSIX systems) and provides the same API as the pure-Python wcwidth package, but with significantly faster execution through Cython compilation.
The library is useful when you need accurate terminal rendering calculations—for instance, when aligning text in CLI tools, formatting table output, or handling mixed-width characters (like CJK ideographs that occupy two columns). It has no runtime dependencies and supports modern Python versions (3.11+) across major platforms with prebuilt wheels.
Use it for
- Calculate display width of strings containing East Asian characters for terminal table formatting.
- Align text output in CLI applications where mixed-width characters must be handled correctly.
- Truncate or pad Unicode strings to fit within a specific terminal column width.
- Build terminal UI libraries that need accurate character width calculations for layout.
- Validate or measure string display length in text processing pipelines.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need fast Unicode display-width calculations for terminal output.
The library is actively maintained, has no security vulnerabilities, carries a permissive license, and offers substantial performance gains over pure-Python alternatives. Install friction is moderate but manageable with prebuilt wheels for all major platforms. Requires Python 3.11+.
Install
cwcwidth on PyPI
Before you install
Medium install friction due to compiled wheels, but well-supported across platforms (macOS arm64/x86_64, Linux x86_64/aarch64, Windows 32/64-bit, musl). Active maintenance with recent release.
Requires Python 3.11 or later.
License in practice
MIT license is permissive; you can use, modify, and distribute cwcwidth freely with minimal restrictions.
Quickstart
pip install cwcwidth
import cwcwidth
print(cwcwidth.wcwidth('a')) # 1
print(cwcwidth.wcswidth('コンニチハ, セカイ!')) # 19
Verify before relying
- Whether performance improvement over wcwidth remains significant in real-world terminal applications beyond the benchmark shown.
- Whether the limited Python API mode (via USE_LIMITED_API environment variable) affects performance or compatibility.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.11 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 286 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 575,923 / month, #5,933 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python Modules |
Evidence: cwcwidth-0.1.12-cp311-abi3-macosx_11_0_arm64.whl; cwcwidth-0.1.12-cp311-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; cwcwidth-0.1.12-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; cwcwidth-0.1.12-cp311-abi3-musllinux_1_2_aarch64.whl; cwcwidth-0.1.12-cp311-abi3-musllinux_1_2_x86_64.whl; cwcwidth-0.1.12-cp311-abi3-win32.whl; cwcwidth-0.1.12-cp311-abi3-win_amd64.whl; cwcwidth-0.1.12-cp311-cp311-macosx_11_0_arm64.whl; cwcwidth-0.1.12-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; cwcwidth-0.1.12-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; cwcwidth-0.1.12-cp311-cp311-musllinux_1_2_aarch64.whl; cwcwidth-0.1.12-cp311-cp311-musllinux_1_2_x86_64.whl; cwcwidth-0.1.12-cp311-cp311-win32.whl; cwcwidth-0.1.12-cp311-cp311-win_amd64.whl; cwcwidth-0.1.12-cp312-cp312-macosx_11_0_arm64.whl; cwcwidth-0.1.12-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; cwcwidth-0.1.12-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; cwcwidth-0.1.12-cp312-cp312-musllinux_1_2_aarch64.whl; cwcwidth-0.1.12-cp312-cp312-musllinux_1_2_x86_64.whl; cwcwidth-0.1.12-cp312-cp312-win32.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “unicode character display width”
- cwcwidthcwcwidth provides fast Python bindings for POSIX wcwidth and wcswidth…
- unicode-segmentation-rsProvides Unicode text segmentation (graphemes, words, sentences, line…
- wcwidthMeasures the displayed width of Unicode strings in terminals,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also wcwidth · cchardet · rtfunicode · win_unicode_console · anyascii · graphemeu · texttable · tangled-up-in-unicode · fold-to-ascii · unicode-segmentation-rs