Roadmap
This document outlines the implementation status of various Python features for CSnakes.
Typing Constructs
Note that any constructs which are not available will be typed as PyObject
. They still work, but the source generator won't generate the automatic marshal and unmarshal code for them. This means that you will have to manually marshal and unmarshal these types in your C# code.
Construct (link) | Supported in CSnakes | Notes | Summary |
---|---|---|---|
Any | Yes | Special type that matches any type. | |
Union | No | No equivalent construct in C#, possibly could use overloads | Accepts one of several types. |
Optional | Yes | Shorthand for a type or None. | |
Literal | No | Possible with enums | Restricts a value to specific literal values. |
Final | No | Would be simple to implement, but not used on function signatures | Indicates a name cannot be reassigned. |
ClassVar | No | Would be simple, but not used on function signatures | Marks a variable as a class variable. |
Generic | No | Relies on class reflection | Base class for generic types. |
TypeVar | Defines a generic type variable. | ||
Callable | No | Callables would have to by Python objects, not C# functions | Represents a callable object (e.g., function). |
Tuple | Yes | Fixed-length, ordered collection of types. | |
List | Yes | Variable-length, ordered collection of types. | |
Dict | Yes | Dictionary mapping keys to values. | |
Set | Usage of sets is quite niche, if you would like this feature please request it. | Unordered collection of unique elements. | |
FrozenSet | As above | Immutable set. | |
Deque | No | Double-ended queue. | |
DefaultDict | No | Use Mapping type instead | Dictionary with a default value for missing keys. |
Counter | No | Use Mapping type instead | Dict subclass for counting hashable objects. |
ChainMap | Groups multiple dicts into a single view. | ||
Type | Indicates a type object. | ||
NewType | No | Not useful for reflection | Creates distinct types for type checking. |
NoReturn | No | Very unlikely to be used, but could be reflected to void |
Indicates a function never returns. |
Self | No | Will be used in class reflection | Refers to the instance type in class bodies. |
Concatenate | No | Very hard to achieve in C# | Used for advanced typing of callable signatures. |
ParamSpec | Used for typing callable parameter lists. | ||
Protocol | Defines structural subtyping (static duck typing). | ||
runtime_checkable | Decorator to allow isinstance checks with Protocols. | ||
Annotated | Adds context-specific metadata to types. | ||
ForwardRef | Internal type for forward references. | ||
overload | No | Issue | Allows function overloading for type checkers. |
Collections ABC
Construct (link) | Supported in CSnakes | Notes | Summary |
---|---|---|---|
Collection (collections.abc) | No | Sized iterable container with contains. | |
Container (collections.abc) | No | Supports membership test using contains. | |
Hashable (collections.abc) | No | Objects with a hash value. | |
ItemsView (collections.abc) | No | View on dictionary's items. | |
Iterable (collections.abc) | No | Issue | Object capable of returning its members one at a time. |
Iterator (collections.abc) | No | Produces items from an iterable. | |
Generator (collections.abc) | Yes | See User Guide for details | Iterator that supports send(), throw(), and close(). |
Mapping (collections.abc) | Yes | Collection of key-value pairs. | |
MappingView (collections.abc) | View on dictionary's keys, values, or items. | ||
MutableMapping (collections.abc) | Mapping that can be changed. | ||
MutableSequence (collections.abc) | No | Use Sequence | Sequence that can be changed. |
MutableSet (collections.abc) | Set that can be changed. | ||
Reversible (collections.abc) | Supports reversed iteration. | ||
Sequence (collections.abc) | Yes | Ordered collection of items. | |
Set (collections.abc) | Unordered collection of unique elements. | ||
Sized (collections.abc) | Has a length. | ||
ValuesView (collections.abc) | View on dictionary's values. | ||
Awaitable (collections.abc) | No | Unlikely to be useful | Can be used in an await expression. |
Coroutine (collections.abc) | Yes | See Async Support | Awaitable object with send(), throw(), and close(). |
AsyncIterable (collections.abc) | No | Issue | Object capable of async iteration. |
AsyncIterator (collections.abc) | No | Issue | Async iterator object. |
Class Reflection
Typed Dict
Construct (link) | Supported in CSnakes | Notes | Summary |
---|---|---|---|
TypedDict | No | Dictionary with a specific set of keys, each with a specific type. | |
NotRequired | No | Marks a key as not required in a TypedDict. | |
Required | No | Marks a key as required in a TypedDict. | |
ReadOnly | No | Marks a key as read-only in a TypedDict. |
Protocols
Construct (link) | Supported in CSnakes | Notes | Summary |
---|---|---|---|
Protocol | No | Defines structural subtyping (static duck typing). |