Skip to content

Standard Library Reference

Sharpy's standard library provides Python-familiar APIs backed by .NET implementations.

Built-in Functions

Built-in functions available without any import: abs(), all(), any(), ascii(), bin(), bool(), breakpoint(), checked_int_pow(), chr(), double(), enumerate(), filter(), float(), format(), format_align(), and 32 more.

Core Types

Type Description
list A mutable sequence of elements, similar to Python's `list`. Supports negative indexing, slicing, and Python-style methods.
dict A mutable mapping of keys to values, similar to Python's dict. Supports Python-style methods like get(), pop(), items(), keys(), and values().
set A mutable set of unique elements, similar to Python's `set`. Supports set operations: union, intersection, difference, and symmetric difference.
complex A complex number type, similar to Python's complex.

Modules

Module Description
argparse Command-line argument parsing.
base64 RFC 4648 base16, base32, base64, and base85 data encodings.
bisect Array bisection algorithm for maintaining sorted lists.
calendar
collections Specialized container datatypes: ChainMap, Counter, Deque, DefaultDict, OrderedDict.
colorsys
configparser Configuration file parser similar to Python's configparser module.
copy
csv CSV file reading and writing.
datetime Classes for working with dates and times.
difflib
email Email message creation and parsing.
fnmatch Unix shell-style filename pattern matching.
fractions
functools Higher-order functions and operations on callable objects.
glob Unix shell-style pathname pattern expansion.
grapheme Unicode grapheme cluster iteration and string width calculation.
gzip Support for gzip compressed files.
hashlib Secure hash and message digest algorithms.
heapq Heap queue (priority queue) algorithm.
hmac Keyed-hashing for message authentication (HMAC).
html HTML processing module.
http HTTP modules — status codes, connections, and responses.
io Core tools for working with streams and file-like objects.
ipaddress Functions to create and manipulate IPv4 and IPv6 addresses and networks.
itertools Functions creating iterators for efficient looping.
json JSON encoder and decoder.
logging Flexible event logging system for applications.
math Mathematical functions.
numpy Numerical computing with multi-dimensional arrays and mathematical operations.
operator
os Miscellaneous operating system interfaces.
pathlib Object-oriented filesystem paths.
platform Access to underlying platform's identifying data.
pprint
random Generate pseudo-random numbers with various distributions.
re Regular expression operations.
requests HTTP library for making requests (GET, POST, PUT, DELETE, etc.).
secrets Generate cryptographically strong random numbers suitable for managing secrets.
shlex Simple lexical analysis of shell-style syntaxes.
shutil Utility functions for copying and removal of files and directory trees.
socket Low-level networking interface, similar to Python's socket module. The bulk of this module (constants, the `socket` wrapper class, the exception hierarchy, DNS helpers, and `create_connection`) is generated from `src/Sharpy.Stdlib/spy/socket_module.spy` into `SocketModule.cs`. The byte-order, inet, and `getaddrinfo` helpers below stay hand-written because they involve `short`/`byte[]` interop and runtime-constructed tuple lists that are cleaner to express directly in C#.
sqlite3 DB-API interface for SQLite databases.
statistics Mathematical statistics functions.
string Common string constants and operations.
struct Interpret bytes as packed binary data.
subprocess Subprocess management: spawn new processes, connect to their pipes, and obtain return codes.
sys System-specific parameters and functions.
tarfile Read and write tar archive files.
tempfile Generate temporary files and directories.
textwrap Text wrapping and filling.
threading Thread-based concurrency primitives.
time Time access and conversions.
toml TOML configuration file parser and encoder.
unittest The unittest module provides a Pythonic testing API that the Sharpy compiler transforms into xUnit test infrastructure during code generation.
urllib URL parsing, quoting, and query string manipulation utilities.
uuid UUID objects (universally unique identifiers) according to RFC 4122.
xml XML processing module (ElementTree API).
yaml YAML parser and emitter.
zipfile Read and write ZIP archive files.
zlib Compression and decompression using zlib.
zoneinfo