icon: dot title: Comparison with CPython
cpython is the reference implementation of the Python programming language. It is written in C and is the most widely used implementation of Python.
pkpy aims to be an alternative to lua for game scripting, not cpython for general purpose programming.
pkpy supports most of the syntax and semantics of python. For performance and simplicity, some features are not implemented, or behave differently. The easiest way to test a feature is to try it on your browser.
__get__ and __set__. However, @property is implemented.__slots__ in class definition.else clause in try..except.__iadd__ and __imul__.__del__ in class definition.StopIteration is returned instead of raised.++i and --j is an increment/decrement statement, not an expression.int does not derive from bool.int is 64-bit. You can use long type explicitly for arbitrary sized integers.__ne__ is not required. Define __eq__ is enough.a, b, *c = x, the starred variable can only be presented in the last position. a, *b, c = x is not supported.Tab is equivalent to 4 spaces. You can mix Tab and spaces in indentation, but it is not recommended.%, &, //, ^ and | for int behave the same as C, not python.str.split and str.splitlines will remove all empty entries.__getattr__, __setattr__ and __delattr__ can only be set in cpp.next() compatible with cpythonYou can use the following code to make next() compatible with cpython temporarily.
import builtins
def next(obj):
res = builtins.next(obj)
if res is StopIteration:
raise StopIteration
return res
a = iter([1])
assert next(a) == 1
try:
next(a)
except StopIteration:
print("a is exhausted")
!!!
Do not change builtins.next. It will break internal functions which rely on StopIteration as return value.
!!!