From d1b06f063385c2cfdb50c0109477f8128b248517 Mon Sep 17 00:00:00 2001 From: BLUELOVETH Date: Tue, 30 May 2023 14:49:53 +0800 Subject: [PATCH] ... --- README.md | 1 - README_zh.md | 1 - docs/features/differences.md | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 docs/features/differences.md diff --git a/README.md b/README.md index 420eaa67..d2e7a9e4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ GitHub GitHub release -

**English |** [**简体中文**](README_zh.md) diff --git a/README_zh.md b/README_zh.md index 1e2cbc53..43722093 100644 --- a/README_zh.md +++ b/README_zh.md @@ -6,7 +6,6 @@ GitHub GitHub release -

pocketpy是一个轻量级的Python解释器,为嵌入至游戏引擎而设计,基于C++17和STL。 diff --git a/docs/features/differences.md b/docs/features/differences.md new file mode 100644 index 00000000..5713048b --- /dev/null +++ b/docs/features/differences.md @@ -0,0 +1,33 @@ +--- +icon: dot +title: Comparison with CPython +order: 99 +--- + +[cpython](https://github.com/python/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. + +## Unimplemented features +1. `**kwargs` in function definition. +2. `__getattr__` and `__setattr__`. +3. Descriptor protocol `__get__` and `__set__`. However, `@property` is implemented. +4. `__slots__` in class definition. +5. `import` module from a directory with `__init__.py`. +6. One element tuple. `(1,)` is not supported. +7. Unpacking in `list` and `dict` literals, i.e. `[1, 2, *a]`. +8. Access the exception object in try..except. + +## Different behaviors +1. positional and keyword arguments are strictly evaluated. +2. When a generator is exhausted, `StopIteration` is returned instead of raised. +3. `++i` and `--j` is an increment/decrement statement, not an expression. \ No newline at end of file