The following built-in functions work similarly to their equivalents in CPython; see the specific functions below for notes
: Currently only implemented for int32's or objects convertible to int32's. The __abs__ attribute is not currently supported.
: Drops the user into an interactive SPy debugging session via spdb, a pdb-like debugging interface for SPy.
: In SPy, dict must always be fully typed and used as dict[keytype, valuetype]., The syntax dict[keytype, valuetype]() can be used to create a new empty dict of the given types. The simpler syntax d: dict[keytype, valuetype] = {} can also be used.
: Unlike CPython, this does not (currently) accept an Iterable to create a new dict from.
: The implementation (in SPy) of dict can be viewed here.
: Returns a list of object’s attributes’ names, the names of its class’s attributes, and recursively of the attributes of its class’s base classes. dir(type) is not currently implemented.
: The no-argument form of dir() (i.e. print local variables) is not currently implemented. Custom __dir__ methods on objects are not currently supported.
: Converts object to a float if able. float is an alias for the f64 type.
: Return the value of the named attribute of object. attr must be blue
: Currently implemented for types: i8,i32, u8, bool, str.
: By default, instances of SPy structs are not hashable. As a planned future feature, structs will have auto-generated __hash__ by default, but this is awaiting implementation. Currently, users can implement the __hash__ function to permit hashing.
: Converts object to an int if able. Works for number types, as well as strings.
: The int type is currently an alias to i32. In the future, int will alias preferred individual types for specific platforms, but currently it is always i32.
: Return the length (the number of items) in a container
: The syntax list[type]() can be used to create a new empty list of the given type. The simpler syntax l: list[membertype] = [] can also be used. Unlike CPython, this does not (currently) accept an Iterable to create a new list from.
: The implementation (in SPy) of list can be viewed here.
: Currently only implemented for int32's or objects convertible to int32's.
: Currently only implemented for int32's or objects convertible to int32's.
: object is implemented as a type, and can be used as a parameter or return type. "Plain" objects (i.e. x = object()) are not supported.
: The print function is currently not variadic, in the sense that it only accepts a single argument. The built-in types are special-cased, and SPy can always print blue objects by pre-computing their string representation
: Creates an iterable set of indices between start and stop, jumping over step indices between each.
: The implementation (in SPy) of range can be viewed here.
: Returns string containing a printable representation of an object.
: Assigns value to the attribute of object named by name. attr must be blue.
: Return a slice object representing the items reached when iterating over range(start, stop, step). The start and step arguments default to None.
: Returns a string version of the object. Selecting an encoding is not currently implemented.
: The syntax tuple[t1, t2, ...](val1, val2 ...) can be used to create a new tuple, with t1 as the type of val1, etc. unlike CPython, this does not (currently) accept an Iterable to create a new tuple from.
: The implementation (in SPy) of tuple can be viewed here.
: Returns the type (i.e. the dynamic type at runtime) of an object
The following CPython built-ins are not currently implemented in SPy. Each category has a brief note about the current state of that category of object or function - some require additional internal mechanics, others are simply lower priority that other facets of the language to this point.
SPy does not currently have an async story.
: aiter(), anext()
Iterables and collections are very much an area of active developmen; as their API solidifies, these types of builtins should become more straightforward to implement.
Generators are not currently supported in SPy.
: all(), any(), enumerate(), filter(), iter(), map(), next(), reversed(), sorted(), sum(), zip()
Number types beyond int and float are in active development; some of the math functions below are also in active development.
: divmod(), bin(), hex(), oct(), pow(), round()
The internals of SPy are significantly different from CPython; as such, the road to (and need for) some of these built-ins is less straightforward. Some are also waiting on internal details to solidify prior to implementation.
: callable(), classmethod(), compile(), delattr(), eval(), exec(), globals(), hasattr(), help(), id(), isinstance(), issubclass(), locals(), property(), super(), vars(). __import__()
Many of these types are not implemented yet; others are in active development.
: ascii(), bool(), bytearray(), bytes(), chr(), complex(), format(), frozenset(), memoryview(), ord() set()
The I/O story is currently a high priority and is in active development.
: input(), open()