mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
2.1 KiB
2.1 KiB
icon | title | order |
---|---|---|
dot | Comparison with CPython | 99 |
cpython is the reference implementation of the Python programming language. It is written in C and is the most widely used implementation of Python.
The design goal
pkpy aims to be an alternative to lua for game scripting, not cpython for general purpose programming.
- For syntax and semantics, pkpy is designed to be as close to cpython as possible.
- For ecosystem and others, pkpy is not compatible with cpython.
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.
Unimplemented features
**kwargs
in function definition.__getattr__
and__setattr__
.- Descriptor protocol
__get__
and__set__
. However,@property
is implemented. __slots__
in class definition.- One element tuple.
(1,)
is not supported. - Unpacking in
list
anddict
literals, e.g.[1, 2, *a]
. - Access the exception object in try..except.
else
clause in try..except.- Inplace methods like
__iadd__
and__imul__
. __del__
in class definition.a = b = 1
, usea, b = 1, 1
instead.
Different behaviors
- positional and keyword arguments are strictly evaluated.
- When a generator is exhausted,
StopIteration
is returned instead of raised. ++i
and--j
is an increment/decrement statement, not an expression.int
does not derive frombool
.int
is not of unlimited precision. In 32 bit system,int
andfloat
is 30 bit; in 64 bit system, they are both 62 bit.__ne__
is not required. Define__eq__
is enough.- Raw string cannot have boundary quotes in it, even escaped. See #55.
- In a starred unpacked assignment, e.g.
a, b, *c = x
, the starred variable can only be presented in the last position.a, *b, c = x
is not supported. a < b < c
does not work as you expected. Usea < b and b < c
instead. (available in main branch now)