Python modules in TypeScript

TypeScript implementations of 56 Python standard library functions across 4 modules. Each function is individually importable and tree-shakeable.

difflib math re string

Help us add more

Got a rainy Sunday afternoon and a taste for a porting puzzle?

We will then review it. If it's useful to the project and in line with our contributing guidelines your work will become part of Locutus and you'll be automatically credited in the authors section accordingly.

Upstream Surface Inventory 56/444 shipped · 181 next 13%

Locutus tracks 25 upstream namespaces for Python and sorts them into what is already shipped, what we still want, what we intentionally keep, and what still needs a decision.

This inventory now targets a broad official core/stdlib slice first, using runtime discovery where possible, rather than the full Python object model or third-party ecosystem.

13% catalog shipped
Shipped Next Explicit non-goals
string 100% math 71% difflib 33% re 31% operator 0% builtins 0% calendar 0% statistics 0% itertools 0% unicodedata 0% urllib.parse 0% textwrap 0% bisect 0% heapq 0% json 0% html 0% csv 0% functools 0% base64 0% cmath 0% collections 0% decimal 0% hashlib 0% hmac 0% random 0%
Tracked namespaces 25
Shipped 56/444
Next to port 181
Explicit non-goals 207

Complete

In progress

math

Python 3.12 · Catalog source: live runtime snapshot python:3.12

71% shipped
40/56 shipped 16 next
Shipped (40)

Next

Python math helpers map cleanly to JS numbers and arrays.

  • cbrt
  • erf
  • erfc
  • exp2
  • fmod
  • frexp
  • gamma
  • ldexp
  • lgamma
  • log1p
  • modf
  • nextafter
  • perm
  • remainder
  • sumprod
  • ulp

difflib

Python 3.12 · Catalog source: live runtime snapshot python:3.12

40% shipped
2/5 shipped 3 next 1 explicit non-goals
Shipped (2)

Next

Sequence-diff helpers are high-value portability targets.

  • context_diff
  • restore
  • unified_diff
Explicit non-goals (1)
  • diff_bytes Skip Byte-oriented diffing does not fit Locutus' current plain-value model.

re

Python 3.12 · Catalog source: live runtime snapshot python:3.12

44% shipped
4/9 shipped 5 next 4 explicit non-goals
re
Shipped (4)

Next

Top-level regex helpers are high-value portability targets.

  • escape
  • fullmatch
  • match
  • search
  • split
Explicit non-goals (4)
  • compile Skip Compiled regex objects are not a stable plain-value target.
  • error Skip Exception types are not standalone plain-value portability targets.
  • purge Skip Regex cache mutation is outside Locutus' portability scope.
  • template Skip Template pattern objects are not a stable plain-value target.

operator

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/34 shipped 34 next 21 explicit non-goals

Next

First-class operator helpers are strong plain-value portability targets.

  • abs
  • add
  • and_
  • concat
  • contains
  • countOf
  • eq
  • floordiv
  • ge
  • getitem
  • gt
  • index
  • indexOf
  • inv
  • invert
  • is_
  • is_not
  • le
  • lshift
  • lt
  • matmul
  • mod
  • mul
  • ne
  • neg
  • not_
  • or_
  • pos
  • pow
  • rshift
  • sub
  • truediv
  • truth
  • xor
Explicit non-goals (21)
  • attrgetter Skip Getter factories return callable objects rather than plain values.
  • call Skip Indirect call wrappers add little value beyond direct JS invocation.
  • delitem Skip Container mutation is outside Locutus' value-only model.
  • iadd Skip In-place operator wrappers imply mutation semantics.
  • iand Skip In-place operator wrappers imply mutation semantics.
  • iconcat Skip In-place operator wrappers imply mutation semantics.
  • ifloordiv Skip In-place operator wrappers imply mutation semantics.
  • ilshift Skip In-place operator wrappers imply mutation semantics.
  • imatmul Skip In-place operator wrappers imply mutation semantics.
  • imod Skip In-place operator wrappers imply mutation semantics.
  • imul Skip In-place operator wrappers imply mutation semantics.
  • ior Skip In-place operator wrappers imply mutation semantics.
  • ipow Skip In-place operator wrappers imply mutation semantics.
  • irshift Skip In-place operator wrappers imply mutation semantics.
  • isub Skip In-place operator wrappers imply mutation semantics.
  • itemgetter Skip Getter factories return callable objects rather than plain values.
  • itruediv Skip In-place operator wrappers imply mutation semantics.
  • ixor Skip In-place operator wrappers imply mutation semantics.
  • length_hint Skip Size-hint probing adds little value beyond direct JS length checks.
  • methodcaller Skip Method-caller factories return callable objects rather than plain values.
  • setitem Skip Container mutation is outside Locutus' value-only model.

builtins

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/33 shipped 33 next 35 explicit non-goals

Next

Scalar absolute-value helpers are strong plain-value targets.

  • abs

Aggregate predicate helpers have a clean plain-value contract.

  • all
  • any

ASCII-safe string representation is a useful plain-value helper.

  • ascii

Integer base conversion has a clean plain-value contract.

  • bin
  • hex
  • oct

Boolean coercion remains a useful plain-value portability target.

  • bool

Callable predicates have a clean plain-value contract.

  • callable

Codepoint-to-string conversion is a strong portability target.

  • chr

Dictionary construction still has a clean plain-value contract.

  • dict

Quotient-remainder helpers have a clean plain-value contract.

  • divmod

Indexed sequence pairing can be represented as plain arrays.

  • enumerate

Predicate-based filtering remains a strong plain-value target.

  • filter

Numeric coercion has a clean plain-value contract.

  • float

String formatting is a strong plain-value portability target.

  • format

Integer coercion is a strong plain-value portability target.

  • int

Size helpers are strong plain-value portability targets.

  • len

Sequence materialization has a clean plain-value contract.

  • list
  • tuple

Mapping over iterables can be represented as plain arrays.

  • map

Aggregate scalar helpers have a clean plain-value contract.

  • max
  • min

String-to-codepoint conversion is a strong portability target.

  • ord

Scalar exponentiation has a clean plain-value contract.

  • pow

Numeric range generation can be represented as plain arrays.

  • range

Representation helpers are useful plain-value string targets.

  • repr

Reversal can be represented as a plain array result.

  • reversed

Scalar rounding remains a strong portability target.

  • round

Sequence sorting has a clean plain-value contract.

  • sorted

String coercion remains a strong plain-value portability target.

  • str

Aggregation helpers are strong plain-value portability targets.

  • sum

Sequence zipping can be represented as plain arrays.

  • zip
Explicit non-goals (35)
  • aiter Skip Python builtins mix pure helpers with runtime introspection, evaluation, I/O, and rich container types too broadly for one direct Locutus wishlist.
  • anext Skip Python builtins mix pure helpers with runtime introspection, evaluation, I/O, and rich container types too broadly for one direct Locutus wishlist.
  • breakpoint Skip Debugger entry mutates runtime execution state.
  • bytearray Skip Mutable byte buffers do not fit Locutus' current plain-value model.
  • bytes Skip Byte strings do not fit Locutus' current plain-value model.
  • classmethod Skip Descriptor factories are not plain-value targets.
  • compile Skip Dynamic code compilation is security-sensitive and not a good Locutus target.
  • complex Skip Complex numbers do not fit Locutus' current plain-value model.
  • delattr Skip Attribute mutation is outside Locutus' value-only model.
  • dir Skip Runtime introspection depends on object model details outside Locutus' scope.
  • eval Skip Dynamic code evaluation is security-sensitive and out of scope.
  • exec Skip Dynamic code execution is security-sensitive and out of scope.
  • frozenset Skip Set semantics do not map cleanly onto Locutus' plain-value model.
  • getattr Skip Generic attribute lookup depends on host object semantics.
  • globals Skip Runtime namespace introspection is outside Locutus' portability scope.
  • hasattr Skip Generic attribute introspection depends on host object semantics.
  • hash Skip Object-hash identity does not map cleanly to JS plain values.
  • id Skip Object identity addresses are not a stable portability target.
  • input Skip Interactive stdin reads depend on host I/O.
  • isinstance Skip Python class introspection does not fit Locutus' plain-value model.
  • issubclass Skip Python class introspection does not fit Locutus' plain-value model.
  • iter Skip Iterator objects are not direct plain-value results.
  • locals Skip Stack-frame introspection is outside Locutus' portability scope.
  • memoryview Skip Buffer-view semantics do not fit Locutus' current plain-value model.
  • next Skip Iterator advancement APIs do not fit Locutus' plain-value model.
  • object Skip Generic object construction has no meaningful plain-value portability target.
  • print Skip Output emission is outside Locutus' value-only model.
  • property Skip Descriptor factories are not plain-value targets.
  • set Skip Set semantics do not map cleanly onto Locutus' plain-value model.
  • setattr Skip Attribute mutation is outside Locutus' value-only model.
  • slice Skip Slice objects are not direct plain-value results.
  • staticmethod Skip Descriptor factories are not plain-value targets.
  • super Skip Method-resolution proxies do not fit Locutus' plain-value model.
  • type Skip Python class introspection does not fit Locutus' plain-value model.
  • vars Skip Runtime namespace introspection is outside Locutus' portability scope.

calendar

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/18 shipped 18 next 1 explicit non-goals

Next

Calendar helpers mostly return scalars, strings, or plain arrays with a useful portability contract.

  • calendar
  • different_locale
  • firstweekday
  • format
  • formatstring
  • isleap
  • leapdays
  • main
  • month
  • monthcalendar
  • monthrange
  • prcal
  • prmonth
  • prweek
  • timegm
  • week
  • weekday
  • weekheader
Explicit non-goals (1)
  • setfirstweekday Skip Global calendar configuration mutates ambient runtime state.

statistics

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/18 shipped 18 next

Next

Aggregate statistics helpers are strong plain-value portability targets.

  • correlation
  • covariance
  • fmean
  • geometric_mean
  • harmonic_mean
  • linear_regression
  • mean
  • median
  • median_grouped
  • median_high
  • median_low
  • mode
  • multimode
  • pstdev
  • pvariance
  • quantiles
  • stdev
  • variance

itertools

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/15 shipped 15 next 5 explicit non-goals

Next

Accumulation over plain iterables can be represented as arrays of intermediate results.

  • accumulate

Fixed-size chunking is a strong plain-value portability target.

  • batched

Sequence concatenation maps naturally onto arrays.

  • chain

Finite combinatorics helpers can be represented as arrays of tuples.

  • combinations
  • combinations_with_replacement
  • permutations

Mask-based filtering has a clean plain-value contract.

  • compress

Predicate-based slicing has a clean plain-value contract.

  • dropwhile
  • takewhile

Predicate-based filtering has a clean plain-value contract.

  • filterfalse

Iterator slicing maps naturally onto array slicing semantics.

  • islice

Adjacent-pair grouping can be represented as arrays of tuples.

  • pairwise

Cartesian products can be represented as arrays of tuples.

  • product

Spread-argument mapping still has a clean plain-value contract.

  • starmap

Sequence zipping has a strong plain-value contract.

  • zip_longest
Explicit non-goals (5)
  • count Skip Many itertools helpers are lazy or stateful iterator factories rather than direct plain values.
  • cycle Skip Many itertools helpers are lazy or stateful iterator factories rather than direct plain values.
  • groupby Skip Many itertools helpers are lazy or stateful iterator factories rather than direct plain values.
  • repeat Skip Many itertools helpers are lazy or stateful iterator factories rather than direct plain values.
  • tee Skip Many itertools helpers are lazy or stateful iterator factories rather than direct plain values.

unicodedata

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/13 shipped 13 next

Next

Unicode classification and normalization helpers are strong plain-value portability targets.

  • bidirectional
  • category
  • combining
  • decimal
  • decomposition
  • digit
  • east_asian_width
  • is_normalized
  • lookup
  • mirrored
  • name
  • normalize
  • numeric

urllib.parse

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/8 shipped 8 next 20 explicit non-goals

Next

Query parsing into plain objects and arrays has a clean portability contract.

  • parse_qs

Query parsing into key-value pairs has a clean portability contract.

  • parse_qsl

URL escaping helpers are strong plain-value portability targets.

  • quote
  • quote_plus

URL unescaping helpers are strong plain-value portability targets.

  • unquote
  • unquote_plus

Query encoding has a clean plain-value portability contract.

  • urlencode

URL joining has a clean plain-value portability contract.

  • urljoin
Explicit non-goals (20)
  • clear_cache Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • quote_from_bytes Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splitattr Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splithost Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splitnport Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splitpasswd Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splitport Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splitquery Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splittag Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splittype Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splituser Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • splitvalue Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • to_bytes Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • unquote_to_bytes Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • unwrap Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • urldefrag Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • urlparse Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • urlsplit Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • urlunparse Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.
  • urlunsplit Skip Parts of urllib.parse return structured parse-result objects rather than one stable plain-value contract.

textwrap

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/5 shipped 5 next

Next

Text formatting and wrapping helpers are strong plain-value portability targets.

  • dedent
  • fill
  • indent
  • shorten
  • wrap

bisect

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/3 shipped 3 next 3 explicit non-goals

Next

Binary-search helpers are strong plain-value portability targets.

  • bisect
  • bisect_left
  • bisect_right
Explicit non-goals (3)
  • insort Skip In-place list insertion mutates caller-owned state.
  • insort_left Skip In-place list insertion mutates caller-owned state.
  • insort_right Skip In-place list insertion mutates caller-owned state.

heapq

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/3 shipped 3 next 5 explicit non-goals

Next

Heap-based selection helpers still have a useful plain-value contract when modeled as array-returning utilities.

  • merge
  • nlargest
  • nsmallest
Explicit non-goals (5)
  • heapify Skip In-place heap mutation is outside Locutus' value-only model.
  • heappop Skip In-place heap mutation is outside Locutus' value-only model.
  • heappush Skip In-place heap mutation is outside Locutus' value-only model.
  • heappushpop Skip In-place heap mutation is outside Locutus' value-only model.
  • heapreplace Skip In-place heap mutation is outside Locutus' value-only model.

json

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/3 shipped 3 next 2 explicit non-goals

Next

JSON encode/decode helpers are strong plain-value portability targets.

  • detect_encoding
  • dumps
  • loads
Explicit non-goals (2)
  • dump Skip File-backed JSON output depends on host I/O resources.
  • load Skip File-backed JSON input depends on host I/O resources.

html

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/2 shipped 2 next

Next

HTML escape and unescape helpers are strong plain-value portability targets.

  • escape
  • unescape

csv

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/1 shipped 1 next 9 explicit non-goals

Next

Dialect enumeration has a clean plain-value contract.

  • list_dialects
Explicit non-goals (9)
  • excel Skip Reader and writer objects are stream-oriented and do not fit one stable plain-value contract by default.
  • excel_tab Skip Reader and writer objects are stream-oriented and do not fit one stable plain-value contract by default.
  • field_size_limit Skip Reader and writer objects are stream-oriented and do not fit one stable plain-value contract by default.
  • get_dialect Skip Reader and writer objects are stream-oriented and do not fit one stable plain-value contract by default.
  • reader Skip Reader and writer objects are stream-oriented and do not fit one stable plain-value contract by default.
  • register_dialect Skip Reader and writer objects are stream-oriented and do not fit one stable plain-value contract by default.
  • unix_dialect Skip Reader and writer objects are stream-oriented and do not fit one stable plain-value contract by default.
  • unregister_dialect Skip Reader and writer objects are stream-oriented and do not fit one stable plain-value contract by default.
  • writer Skip Reader and writer objects are stream-oriented and do not fit one stable plain-value contract by default.

functools

Python 3.12 · Catalog source: live runtime snapshot python:3.12

0% shipped
0/1 shipped 1 next 11 explicit non-goals

Next

Left-folding over plain iterables is a strong portability target.

  • reduce
Explicit non-goals (11)
  • cache Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • cached_property Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • cmp_to_key Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • lru_cache Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • partial Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • partialmethod Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • singledispatch Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • singledispatchmethod Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • total_ordering Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • update_wrapper Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.
  • wraps Skip Most functools exports are decorators, wrappers, or callable factories rather than plain values.

Triaged as out of scope

base64 Python 3.12
0/0 21 skipped
cmath Python 3.12
0/0 23 skipped
collections Python 3.12
0/0 3 skipped
decimal Python 3.12
0/0 3 skipped
hashlib Python 3.12
0/0 16 skipped
hmac Python 3.12
0/0 2 skipped
random Python 3.12
0/0 22 skipped