pocketpy/resources/js/search.json
2025-10-08 13:58:13 +00:00

1 line
45 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[[{"l":"Welcome to pocketpy","p":["pocketpy is a portable Python 3.x interpreter, written in C11. It aims to be an alternative to Lua for game scripting, with elegant syntax, powerful features and competitive performance. pocketpy has no dependencies other than the C standard library, which can be easily integrated into your C/C++ project. Developers are able to write Python bindings via C-API or pybind11 compatible interfaces.","Live Python Demo: Run Python code in your browser","Live C Examples: Explore C-APIs in your browser","Godot Extension: Use pocketpy in Godot Engine","VSCode Extension: Debug and profile pocketpy scripts in VSCode","Flutter Plugin: Use pocketpy in Flutter apps"]},{"l":"What it looks like"},{"l":"Supported platforms","p":["pkpy should work on any platform with a C11 compiler. These platforms are officially tested.","Windows 64-bit","Linux 64-bit / 32-bit","macOS 64-bit","Android 64-bit / 32-bit","iOS 64-bit","Emscripten 32-bit","Raspberry Pi OS 64-bit"]},{"l":"Star the repo","p":["If you find pkpy useful, consider star this repository(●'◡'●)"]},{"l":"Sponsor this project","p":["You can sponsor this project via these ways.","Github Sponsors","Buy me a coffee","Your sponsorship will help us develop pkpy continuously."]},{"l":"Upgrade to v2.0","p":["pkpy v2.0 is a C11 project instead of C++ 17. All your existing code for v1.x won't work anymore.","We provide two API sets for v2.0, C-API and pybind11 API (C++17). If you are a C user, use the C-API. If you are a C++ user, use the pybind11 API."]}],[{"l":"Quick Start","p":["You have two options to integrate pkpy into your project."]},{"l":"Use the single header file","p":["Download the pocketpy.h and pocketpy.c on our GitHub Release page. And #include it in your project."]},{"l":"Use CMake","p":["Clone the whole repository as a submodule into your project, In your CMakelists.txt, add the following lines:","See CMakeLists.txt for details.","It is safe to use main branch in production if CI badge is green."]},{"l":"Compile flags","p":["To compile it with your project, these flags must be set:","--std=c11 flag must be set","For MSVC, /utf-8 and /experimental:c11atomics flag must be set","NDEBUG macro should be defined for release build, or you will get poor performance"]},{"l":"Get prebuilt binaries","p":["We have prebuilt binaries, check them out on our GitHub Actions.","You can download an artifact there which contains the following files."]},{"l":"Example"}],[{"l":"Write C Bindings","p":["In order to use a C/C++ library in python, you need to write bindings for it.","pkpy uses an universal signature to wrap a C function pointer as a python function or method, i.e py_CFunction.","argc is the number of arguments passed to the function.","argv is the pointer to the first argument.","If successful, the function should return true and set the return value in py_retval(). In case there is no return value, you should use py_newnone(py_retval()). If an error occurs, the function should raise an exception and return false."]},{"l":"Steps","p":["Say you have a function add that takes two integers and returns their sum.","Here is how you can write the binding for it:","Once you have the wrapper function, you can bind it to a python module via py_bindfunc.","Alternatively, you can use py_bind with a signature, which allows you to specify some default values.","See also:","py_bind","py_bindmethod","py_bindfunc","py_bindproperty","py_newmodule","py_newtype"]}],[{"l":"Write C++ Bindings"},{"l":"Quick Start","p":["pkpy provides a pybind11 compatible layer which allows users to do convenient bindings.","To begin with, use py::scoped_interpreter guard{} to start the interpreter before using any Python objects. Or explicitly call py::interpreter::initialize() and py::interpreter::finalize()."]},{"l":"module"},{"l":"function"},{"l":"class"},{"l":"operators"},{"l":"py::object","p":["py::object is just simple wrapper around PyVar. It supports some convenient methods to interact with Python objects.","here are some common methods:","you can also create some builtin objects with their according wrappers:"]},{"l":"More Examples","p":["More examples please see the test folder in the GSoC repository. All tested features are supported."]},{"l":"Limits and Comparison","p":["This is a feature list of pybind11 for pocketpy. It lists all completed and pending features. It also lists the features that cannot be implemented in the current version of pocketpy."]},{"i":"function-1","l":"Function","p":["Function overloading","Return value policy","is_prepend","*args and **kwargs","Keep-alive","Call Guard","Default arguments","Keyword-Only arguments","Positional-Only arguments","Allow/Prohibiting None arguments"]},{"i":"class-1","l":"Class","p":["Creating bindings for a custom type","Binding lambda functions","Dynamic attributes","Inheritance and automatic downcasting","Enumerations and internal types","Instance and static fields","Binding static fields may never be implemented in pocketpy because it requires a metaclass, which is a heavy and infrequently used feature."]},{"l":"Exceptions","p":["Need further discussion."]},{"l":"Smart pointers","p":["std::shared_ptr","std::unique_ptr","Custom smart pointers"]},{"l":"Type conversions","p":["Python built-in types","STL Containers","Functional","Chrono"]},{"l":"Python C++ interface","p":["bool_","buffer","bytearray","bytes","capsule","dict","float_","function","int_","iterable","iterator","list","memoryview","Need further discussion.","none","object","set","slice","str","tuple","type"]},{"l":"Miscellaneous","p":["Global Interpreter Lock (GIL)","Binding sequence data types, iterators, the slicing protocol, etc.","Convenient operators binding"]},{"l":"Differences between CPython and pocketpy","p":["only add, sub and mul have corresponding right versions in pocketpy. So if you bind int() py::self, it will has no effect in pocketpy.","__new__ and __del__ are not supported in pocketpy.","in-place operators, such as +=, -=, *=, etc., are not supported in pocketpy.","the return value of globals is immutable in pocketpy."]}],[{"l":"Basic Features","p":["(1, 2, 'a')","[1, 2, 'a']","[i for i in range(5)]","{'a': 1, 'b': 2}","@cache","✅","a, *b = [1, 2, 3]","a, b = 1, 2","a[1:2], a[:2], a[1:]","class A(B):","Context Block","Decorator","def f(a:int, b:float=1)","def f(x,*args,y=1):","Dict","Dynamic Code","eval()/exec()","Example","Exception","F-String","f'value is {x}'","for/while/break/continue","Function","Generator","hasattr()/getattr()/setattr()","If Else","if..else..elif","Import","import/from..import","List","ListComp","Loop","Match Case","match code: case 200:","Name","raise/try..except..","Reflection","Slice","Star Unpacking","Subclass","Supported","The following table shows the basic features of pkpy with respect to cpython.","Tuple","Type Annotation","Unpacking","with expr as id:","yield i"]},{"l":"Supported magic methods"},{"l":"Unary operators","p":["__repr__","__str__","__hash__","__len__","__iter__","__next__","__neg__"]},{"l":"Logical operators","p":["__eq__","__lt__","__le__","__gt__","__ge__","__contains__"]},{"l":"Binary operators","p":["__add__","__and__","__floordiv__","__invert__","__lshift__","__matmul__","__mod__","__mul__","__or__","__pow__","__radd__","__rmul__","__rshift__","__rsub__","__sub__","__truediv__","__xor__"]},{"l":"Indexer","p":["__getitem__","__setitem__","__delitem__"]},{"l":"Specials","p":["__new__","__init__","__call__","__divmod__","__enter__","__exit__","__name__","__all__"]}],[{"l":"Comparison with CPython","p":["cpython is the reference implementation of the Python programming language. It is written in C and is the most widely used implementation of Python."]},{"l":"The design goal","p":["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."]},{"l":"Unimplemented features","p":["Descriptor protocol __get__ and __set__. However, @property is implemented.","__slots__ in class definition.","else clause in try..except.","Inplace methods like __iadd__ and __imul__.","__del__ in class definition.","Multiple inheritance."]},{"l":"Different behaviors","p":["positional and keyword arguments are strictly evaluated.","int does not derive from bool.","int is 64-bit.","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 Tab is equivalent to 4 spaces. You can mix Tab and spaces in indentation, but it is not recommended.","A return, break, continue in try/except/with block will make the finally block not executed.","match is a keyword and match..case is equivalent to if..elif..else."]}],[{"l":"Debugging"},{"l":"Install VSCode Extension","p":["To debug a pocketpy program, you need to install our VSCode extension first:","https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy","The VSCode extension requires pocketpy version >= 2.1.1"]},{"l":"Create a launch.json file","p":["Navigate to the Debug view in VSCode, and click on \"create a launch.json file\" link. In the dropdown menu, select \"pocketpy\".","launch_json","Then a default launch.json file will be created in the .vscode folder with a sample pocketpy debug configuration."]},{"l":"How does it work?","p":["pocketpy provides a C-API py_debugger_waitforattach, which starts a debug server and waits for the VSCode extension to attach. When the debugger is attached, the program will continue to run.","If you are using pocketpy's standalone executable main.exe, you can pass --debug flag to it. This will automatically call py_debugger_waitforattach(127.0.0.1, 6110) before running your program.","If you are embedding pocketpy as a library, you need to call py_debugger_waitforattach manually in your C/C++ code."]},{"l":"Configuration","p":["type: must be pocketpy","request: can be attach or launch","name: the name of this configuration","port: the port number of the debug server, must match the one in py_debugger_waitforattach","host: the host of the debug server, must match the one in py_debugger_waitforattach","sourceFolder: the root folder of your python source code, default to ${workspaceFolder}. However, sometimes you may run your program from a subfolder, in this case you need to set sourceFolder to the correct path. If this is not set correctly, breakpoints will not be hit.","program: (for launch mode only) the path to the executable file which calls py_debugger_waitforattach, e.g. the pocketpy standalone executable main.exe.","args: (for launch mode only) the arguments to pass to the executable file, e.g. --debug and the script path if you are using main.exe.","cwd: (for launch mode only) the working directory to launch the executable file, default to ${workspaceFolder}."]},{"l":"For attach mode","p":["In this mode, you need to start your pocketpy program manually which must call py_debugger_waitforattach first. After the program starts, you can let VSCode attach to the debug server."]},{"l":"For launch mode","p":["In this mode, VSCode will start your program with the specified program, args and cwd. After the program starts, VSCode attempts to attach to the debug server automatically."]},{"l":"Showcase","p":["debugger_demo"]}],[{"l":"Profiling","p":["To profile your pocketpy program, you can run main.exe with --profile flag.","For example, to profile test/test_math.py, run","This will output a JSON report file named profile_report.json in the current directory, which records the time spent for each line. To visualize the report, please install our VSCode extension.","https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy","The VSCode extension requires pocketpy version >= 2.1.1","With pocketpy VSCode extension, press F1 and type pocketpy: Load Line Profiler Report, select 1. the profile_report.json file; 2. the source root of the program. Then you will see a nice visualization of the profiling result.","profiler_report","Press ESC to exit the report view."]}],[{"l":"Threading","p":["pocketpy organizes its state by VM structure. Users can have at maximum 16 VM instances (index from 0 to 15). Each VM instance can only be accessed by exactly one thread at a time. If you are trying to run two python scripts in parallel refering the same VM instance, you will crash it definitely.","However, there are two ways to achieve multi-threading in pocketpy.","One way is to use a native threading library such as pthread. You can wrap the multi-threading logic into a C function and bind it to pocketpy. Be careful and not to access the same VM instance from multiple threads at the same time. You need to lock critical resources or perform a deep copy of all needed data."]},{"l":"ComputeThread","p":["The other way is to use pkpy.ComputeThread. It is like an isolate in Dart language. ComputeThread is a true multi-threading model to allow you run python scripts in parallel without lock, backed by a separate VM instance.","ComputeThread is highly designed for computational intensive tasks in games. For example, you can run game logic in main thread (VM 0) and run world generation in another thread (e.g. VM 1)."]},{"l":"main.py"},{"l":"worldgen.py","p":["Run main.py and you will see the result like this:","ComputeThread uses pickle module to serialize the data between threads. Parameters and return values must be supported by pickle. See pickle for more details.","Since ComputeThread is backed by a separate VM instance, it does not share any state with the main thread except for the parameters you pass to it. Therefore, common python modules will be imported twice in each thread.","If you want to identify which VM instance the module is running in, you can call pkpy.currentvm or let your ComputeThread set some special flags before importing these modules."]}],[{"l":"Undefined Behaviour","p":["These are the undefined behaviours of pkpy. The behaviour of pkpy is undefined if you do the following things.","Delete a builtin object. For example, del int.__add__.","Call an unbound method with the wrong type of self. For example, int.__add__('1', 2).","Type T's __new__ returns an object that is not an instance of T.","Call __new__ with a type that is not a subclass of type."]}],[{"l":"Introduction","p":["All public functions in the C API are prefixed with py_ in pocketpy.h."]},{"l":"Overview","p":["pocketpy works with opaque references. py_Ref is used to reference objects in the virtual machine. It is your responsibility to ensure a reference is valid before using it. See following reference types:","You can store python objects into \"stack\" or \"register\". We provide 8 registers and you can get references to them by py_reg(). Also, py_retval() is a special register that is used to store the return value of a py_CFunction. Registers are shared so they could be overwritten easily. If you want to store python objects across function calls, you should store them into the stack via py_push() and py_pop()."]},{"l":"Data Types","p":["(void*)py_toint()","bool","C to Python","C type","char,short,int,long","const char*","float","float,double","int","py_newbool()","py_newfloat()","py_newint()","py_newstr()","py_tobool()","py_tofloat(), py_castfloat()","py_toint()","py_tostr()","Python to C","Python type","str","void*,intptr_t","You can do conversions between C types and python objects using the following functions:"]},{"l":"PY_RAISE macro","p":["Mark a function that can raise an exception on failure.","If the function returns bool, then false means an exception is raised.","If the function returns int, then -1 means an exception is raised."]},{"l":"PY_RETURN macro","p":["Mark a function that can store a value in py_retval() on success."]}],[{"l":"Functions"},{"l":"py_initialize"},{"l":"py_finalize"},{"l":"py_currentvm"},{"l":"py_switchvm"},{"l":"py_resetvm"},{"l":"py_resetallvm"},{"l":"py_getvmctx"},{"l":"py_setvmctx"},{"l":"py_callbacks"},{"l":"py_sys_setargv"},{"l":"py_sys_settrace"},{"l":"py_gc_collect"},{"l":"py_malloc"},{"l":"py_realloc"},{"l":"py_free"},{"l":"py_True"},{"l":"py_False"},{"l":"py_None"},{"l":"py_NIL"},{"l":"py_Frame_newglobals"},{"l":"py_Frame_newlocals"},{"l":"py_Frame_function"},{"l":"py_compile"},{"l":"py_exec"},{"l":"py_eval"},{"l":"py_smartexec"},{"l":"py_smarteval"},{"l":"py_newint"},{"l":"py_newtrivial"},{"l":"py_newfloat"},{"l":"py_newbool"},{"l":"py_newstr"},{"l":"py_newstrn"},{"l":"py_newstrv"},{"l":"py_newfstr"},{"l":"py_newnone"},{"l":"py_newnotimplemented"},{"l":"py_newellipsis"},{"l":"py_newnil"},{"l":"py_newnativefunc"},{"l":"py_newfunction"},{"l":"py_newboundmethod"},{"l":"py_newobject"},{"l":"py_name"},{"l":"py_name2ref"},{"l":"py_namev"},{"l":"py_name2sv"},{"l":"py_bind"},{"l":"py_bindmethod"},{"l":"py_bindstaticmethod"},{"l":"py_bindfunc"},{"l":"py_bindproperty"},{"l":"py_bindmagic"},{"l":"py_macrobind"},{"l":"py_macroget"},{"l":"py_toint"},{"l":"py_totrivial"},{"l":"py_tofloat"},{"l":"py_castfloat"},{"l":"py_castfloat32"},{"l":"py_castint"},{"l":"py_tobool"},{"l":"py_totype"},{"l":"py_touserdata"},{"l":"py_tosv"},{"l":"py_bytes_resize"},{"l":"py_newtype"},{"l":"py_istype"},{"l":"py_typeof"},{"l":"py_isinstance"},{"l":"py_issubclass"},{"l":"py_gettype"},{"l":"py_checktype"},{"l":"py_checkinstance"},{"l":"py_tpfindmagic"},{"l":"py_tpfindname"},{"l":"py_tpbase"},{"l":"py_tpobject"},{"l":"py_tpsetfinal"},{"l":"py_tphookattributes"},{"l":"py_inspect_currentfunction"},{"l":"py_inspect_currentmodule"},{"l":"py_inspect_currentframe"},{"l":"py_newglobals"},{"l":"py_newlocals"},{"l":"py_getreg"},{"l":"py_setreg"},{"l":"py_retval"},{"l":"py_getdict"},{"l":"py_setdict"},{"l":"py_deldict"},{"l":"py_emplacedict"},{"l":"py_applydict"},{"l":"py_cleardict"},{"l":"py_getslot"},{"l":"py_setslot"},{"l":"py_getbuiltin"},{"l":"py_getglobal"},{"l":"py_setglobal"},{"l":"py_peek"},{"l":"py_push"},{"l":"py_pushnil"},{"l":"py_pushnone"},{"l":"py_pushname"},{"l":"py_pop"},{"l":"py_shrink"},{"l":"py_pushtmp"},{"l":"py_pushmethod"},{"l":"py_pusheval"},{"l":"py_vectorcall"},{"l":"py_call"},{"l":"py_tpcall"},{"l":"py_callcfunc"},{"l":"py_binaryop"},{"l":"py_binaryadd"},{"l":"py_binarysub"},{"l":"py_binarymul"},{"l":"py_binarytruediv"},{"l":"py_binaryfloordiv"},{"l":"py_binarymod"},{"l":"py_binarypow"},{"l":"py_binarylshift"},{"l":"py_binaryrshift"},{"l":"py_binaryand"},{"l":"py_binaryor"},{"l":"py_binaryxor"},{"l":"py_binarymatmul"},{"l":"py_eq"},{"l":"py_ne"},{"l":"py_lt"},{"l":"py_le"},{"l":"py_gt"},{"l":"py_ge"},{"l":"py_isidentical"},{"l":"py_bool"},{"l":"py_equal"},{"l":"py_less"},{"l":"py_callable"},{"l":"py_hash"},{"l":"py_iter"},{"l":"py_next"},{"l":"py_str"},{"l":"py_repr"},{"l":"py_len"},{"l":"py_getattr"},{"l":"py_setattr"},{"l":"py_delattr"},{"l":"py_getitem"},{"l":"py_setitem"},{"l":"py_delitem"},{"l":"py_getmodule"},{"l":"py_newmodule"},{"l":"py_importlib_reload"},{"l":"py_import"},{"l":"py_checkexc"},{"l":"py_matchexc"},{"l":"py_clearexc"},{"l":"py_printexc"},{"l":"py_formatexc"},{"l":"py_exception"},{"l":"py_raise"},{"l":"KeyError"},{"l":"StopIteration"},{"l":"py_debugger_waitforattach"},{"l":"py_debugger_status"},{"l":"py_debugger_exceptionbreakpoint"},{"l":"py_debugger_exit"},{"l":"py_newtuple"},{"l":"py_tuple_data"},{"l":"py_tuple_getitem"},{"l":"py_tuple_setitem"},{"l":"py_tuple_len"},{"l":"py_newlist"},{"l":"py_newlistn"},{"l":"py_list_data"},{"l":"py_list_getitem"},{"l":"py_list_setitem"},{"l":"py_list_delitem"},{"l":"py_list_len"},{"l":"py_list_swap"},{"l":"py_list_append"},{"l":"py_list_emplace"},{"l":"py_list_clear"},{"l":"py_list_insert"},{"l":"py_newdict"},{"l":"py_dict_getitem"},{"l":"py_dict_setitem"},{"l":"py_dict_delitem"},{"l":"py_dict_getitem_by_str"},{"l":"py_dict_getitem_by_int"},{"l":"py_dict_setitem_by_str"},{"l":"py_dict_setitem_by_int"},{"l":"py_dict_delitem_by_str"},{"l":"py_dict_delitem_by_int"},{"l":"py_dict_apply"},{"l":"py_dict_len"},{"l":"py_newslice"},{"l":"py_newsliceint"},{"l":"py_newRandom"},{"l":"py_Random_seed"},{"l":"py_Random_random"},{"l":"py_Random_uniform"},{"l":"py_Random_randint"},{"l":"py_newarray2d"},{"l":"py_array2d_getwidth"},{"l":"py_array2d_getheight"},{"l":"py_array2d_getitem"},{"l":"py_array2d_setitem"},{"l":"py_newvec2"},{"l":"py_newvec3"},{"l":"py_newvec2i"},{"l":"py_newvec3i"},{"l":"py_newcolor32"},{"l":"py_newmat3x3"},{"l":"py_tovec2"},{"l":"py_tovec3"},{"l":"py_tovec2i"},{"l":"py_tovec3i"},{"l":"py_tomat3x3"},{"l":"py_tocolor32"},{"l":"py_json_dumps"},{"l":"py_json_loads"},{"l":"py_pickle_dumps"},{"l":"py_pickle_loads"},{"l":"py_watchdog_begin"},{"l":"py_watchdog_end"},{"l":"py_profiler_begin"},{"l":"py_profiler_end"},{"l":"py_profiler_reset"},{"l":"py_profiler_report"},{"l":"py_replinput"}],[{"l":"array2d","p":["Efficient general-purpose 2D array."]},{"l":"Source code"}],[{"l":"base64"},{"l":"base64.b64encode(b: bytes) - bytes","p":["Encode bytes-like object b using the standard Base64 alphabet."]},{"l":"base64.b64decode(b: str | bytes) - bytes","p":["Decode Base64 encoded bytes-like object b."]}],[{"l":"bisect"},{"l":"bisect.bisect_left(a, x)","p":["Return the index where to insert item x in list a, assuming a is sorted."]},{"l":"bisect.bisect_right(a, x)","p":["Return the index where to insert item x in list a, assuming a is sorted."]},{"l":"bisect.insort_left(a, x)","p":["Insert item x in list a, and keep it sorted assuming a is sorted.","If x is already in a, insert it to the left of the leftmost x."]},{"l":"bisect.insort_right(a, x)","p":["Insert item x in list a, and keep it sorted assuming a is sorted.","If x is already in a, insert it to the right of the rightmost x."]},{"l":"Source code"}],[{"l":"cmath","p":["Mathematical functions for complex numbers.","https://docs.python.org/3/library/cmath.html"]},{"l":"Source code"}],[{"l":"collections"},{"l":"collections.Counter(iterable)","p":["Return a dict containing the counts of each element in iterable."]},{"l":"collections.deque","p":["A double-ended queue."]},{"l":"collections.defaultdict","p":["A dictionary that returns a default value when a key is not found."]},{"l":"Source code"}],[{"l":"colorcvt","p":["Provide color conversion functions."]},{"l":"Source code"}],[{"l":"cute_png","p":["This module is optional. Set option PK_BUILD_MODULE_CUTE_PNG to ON in your CMakeLists.txt to enable it.","Wraps cute_png.h for PNG image loading and saving."]},{"l":"Source code"}],[{"l":"dataclasses"},{"l":"dataclasses.dataclass","p":["A decorator that is used to add special method to classes, including __init__, __repr__ and __eq__."]},{"l":"dataclasses.asdict(obj) - dict","p":["Convert a dataclass instance to a dictionary."]},{"l":"Source code"}],[{"l":"datetime"},{"l":"datetime.now()","p":["Returns the current date and time as a datetime object."]},{"l":"date.today()","p":["Returns the current local date as a date object."]},{"l":"Source code"}],[{"l":"easing","p":["easing.InBack(t: float) - float","easing.InBounce(t: float) - float","easing.InCirc(t: float) - float","easing.InCubic(t: float) - float","easing.InElastic(t: float) - float","easing.InExpo(t: float) - float","easing.InOutBack(t: float) - float","easing.InOutBounce(t: float) - float","easing.InOutCirc(t: float) - float","easing.InOutCubic(t: float) - float","easing.InOutElastic(t: float) - float","easing.InOutExpo(t: float) - float","easing.InOutQuad(t: float) - float","easing.InOutQuart(t: float) - float","easing.InOutQuint(t: float) - float","easing.InOutSine(t: float) - float","easing.InQuad(t: float) - float","easing.InQuart(t: float) - float","easing.InQuint(t: float) - float","easing.InSine(t: float) - float","easing.Linear(t: float) - float","easing.OutBack(t: float) - float","easing.OutBounce(t: float) - float","easing.OutCirc(t: float) - float","easing.OutCubic(t: float) - float","easing.OutElastic(t: float) - float","easing.OutExpo(t: float) - float","easing.OutQuad(t: float) - float","easing.OutQuart(t: float) - float","easing.OutQuint(t: float) - float","easing.OutSine(t: float) - float","Python wrapper for easing functions."]}],[{"l":"enum"},{"l":"enum.Enum","p":["Base class for creating enumerated constants.","Example:"]}],[{"l":"functools"},{"l":"functools.cache","p":["A decorator that caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned, and not re-evaluated."]},{"l":"functools.lru_cache(maxsize=128)","p":["A decorator that wraps a function with a memoizing callable that saves up to the maxsize most recent calls."]},{"l":"functools.reduce(function, sequence, initial=...)","p":["Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, functools.reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). The left argument, x, is the accumulated value and the right argument, y, is the update value from the sequence. If the optional initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty."]},{"l":"functools.partial(f, *args, **kwargs)","p":["Return a new partial object which when called will behave like f called with the positional arguments args and keyword arguments kwargs. If more arguments are supplied to the call, they are appended to args. If additional keyword arguments are supplied, they extend and override kwargs."]},{"l":"Source code"}],[{"l":"gc"},{"l":"gc.collect()","p":["Invoke the garbage collector."]},{"l":"gc.enable()","p":["Enable automatic garbage collection."]},{"l":"gc.disable()","p":["Disable automatic garbage collection."]},{"l":"gc.isenabled()","p":["Return True if automatic garbage collection is enabled, False otherwise."]}],[{"l":"heapq"},{"l":"heapq.heappush(heap, item)","p":["Push the value item onto the heap, maintaining the heap invariant."]},{"l":"heapq.heappop(heap)","p":["Pop and return the smallest item from the heap, maintaining the heap invariant. If the heap is empty, IndexError is raised. To access the smallest item without popping it, use heap[0]."]},{"l":"heapq.heapify(x)","p":["Transform list x into a heap, in-place, in linear time."]},{"l":"heapq.heappushpop(heap, item)","p":["Push item on the heap, then pop and return the smallest item from the heap. The combined action runs more efficiently than heappush() followed by a separate heappop()."]},{"l":"heapq.heapreplace(heap, item)","p":["Pop and return the smallest item from the heap, and also push the new item. The heap size doesnt change. If the heap is empty, IndexError is raised."]},{"l":"Source code"}],[{"l":"importlib"},{"l":"importlib.reload(module)","p":["Reload a previously imported module. The argument must be a module object, so it must have been successfully imported before. This is useful if you have edited the module source file using an external editor and want to try out the new version without leaving the Python interpreter. The return value is the module object (the same as the argument)."]}],[{"l":"json"},{"l":"json.loads(data: str)","p":["Decode a JSON string into a python object."]},{"l":"json.dumps(obj, indent=0) - str","p":["Encode a python object into a JSON string."]}],[{"l":"libhv","p":["This module is optional. Set option PK_BUILD_MODULE_LIBHV to ON in your CMakeLists.txt to enable it.","libhv is a git submodule located at 3rd/libhv/libhv. If you cannot find it, please run the following command to initialize the submodule:","Simple bindings for libhv, which provides cross platform implementation of the following:","HTTP server","HTTP client","WebSocket server","WebSocket client"]},{"l":"Source code"}],[{"l":"lz4","p":["This module is optional. Set option PK_BUILD_MODULE_LZ4 to ON in your CMakeLists.txt to enable it.","LZ4 compression and decompression."]},{"l":"Source code"}],[{"l":"math"},{"l":"math.pi","p":["3.141592653589793"]},{"l":"math.e","p":["2.718281828459045"]},{"l":"math.inf","p":["The inf."]},{"l":"math.nan","p":["The nan."]},{"l":"math.ceil(x)","p":["Return the ceiling of x as a float, the smallest integer value greater than or equal to x."]},{"l":"math.fabs(x)","p":["Return the absolute value of x."]},{"l":"math.floor(x)","p":["Return the floor of x as a float, the largest integer value less than or equal to x."]},{"l":"math.fsum(iterable)","p":["Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:"]},{"l":"math.gcd(a, b)","p":["Return the greatest common divisor of the integers a and b."]},{"l":"math.isfinite(x)","p":["Return True if x is neither an infinity nor a NaN, and False otherwise."]},{"l":"math.isinf(x)","p":["Return True if x is a positive or negative infinity, and False otherwise."]},{"l":"math.isnan(x)","p":["Return True if x is a NaN (not a number), and False otherwise."]},{"l":"math.isclose(a, b)","p":["Return True if the values a and b are close to each other and False otherwise."]},{"l":"math.exp(x)","p":["Return e raised to the power of x."]},{"l":"math.log(x)","p":["Return the natural logarithm of x(to base e)."]},{"l":"math.log2(x)","p":["Return the base-2 logarithm of x. This is usually more accurate than log(x, 2)."]},{"l":"math.log10(x)","p":["Return the base-10 logarithm of x. This is usually more accurate than log(x, 10)."]},{"l":"math.pow(x, y)","p":["Return x raised to the power y."]},{"l":"math.sqrt(x)","p":["Return the square root of x."]},{"l":"math.acos(x)","p":["Return the arc cosine of x, in radians."]},{"l":"math.asin(x)","p":["Return the arc sine of x, in radians."]},{"l":"math.atan(x)","p":["Return the arc tangent of x, in radians."]},{"l":"math.atan2(y, x)","p":["Return atan(y / x), in radians. The result is between -pi and pi. The vector in the plane from the origin to point (x, y) makes this angle with the positive X axis. The point of atan2() is that the signs of both inputs are known to it, so it can compute the correct quadrant for the angle. For example, atan(1) and atan2(1, 1) are both pi/4, but atan2(-1, -1) is -3*pi/4."]},{"l":"math.cos(x)","p":["Return the cosine of x radians."]},{"l":"math.sin(x)","p":["Return the sine of x radians."]},{"l":"math.tan(x)","p":["Return the tangent of x radians."]},{"l":"math.degrees(x)","p":["Convert angle x from radians to degrees."]},{"l":"math.radians(x)","p":["Convert angle x from degrees to radians."]},{"l":"math.modf(x)","p":["Return the fractional and integer parts of x. Both results carry the sign of x and are floats."]},{"l":"math.copysign(x, y)","p":["Return a float with the magnitude (absolute value) of x but the sign of y."]},{"l":"math.factorial(x)","p":["Return x factorial as an integer."]}],[{"l":"operator","p":["The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expression x+y. Many function names are those used for special methods, without the double underscores."]},{"l":"Mapping Operators to Functions","p":["-a","~a","a - b","a != b","a @ b","a * b","a ** b","a / b","a // b","a % b","a ^ b","a + b","a = b","a == b","a | b","a b","a is b","a is not b","a[b]","a[b] = c","add(a, b)","Addition","and_(a, b)","b in a","Bitwise AND","Bitwise Inversion","Bitwise OR","Bitwise XOR","bool(a)","Containment Test","contains(a, b)","del a[b]","delitem(a, b)","Division","eq(a, b)","Equality","Exponentiation","floordiv(a, b)","Function","ge(a, b)","getitem(a, b)","gt(a, b)","Identity","Index Assignment","Index Deletion","Indexing","invert(a)","is_(a, b)","is_not(a, b)","le(a, b)","Left Shift","lshift(a, b)","lt(a, b)","matmul(a, b)","Matrix Multiplication","mod(a, b)","Modulo","mul(a, b)","Multiplication","ne(a, b)","neg(a)","Negation (Arithmetic)","Negation (Logical)","not a","not_(a)","Operation","or_(a, b)","Ordering","pow(a, b)","Right Shift","rshift(a, b)","setitem(a, b, c)","sub(a, b)","Subtraction","Syntax","truediv(a, b)","Truth Test","truth(a)","xor(a, b)"]},{"l":"In-place Operators","p":["a -= b","a *= b","a //= b","a /= b","a %= b","a ^= b","a += b","a = b","a |= b","Addition","Bitwise AND","Bitwise OR","Bitwise XOR","Division","Function","iadd(a, b)","iand(a, b)","ifloordiv(a, b)","ilshift(a, b)","imod(a, b)","imul(a, b)","ior(a, b)","irshift(a, b)","isub(a, b)","itruediv(a, b)","ixor(a, b)","Left Shift","Modulo","Multiplication","Operation","Right Shift","Subtraction","Syntax"]}],[{"l":"pickle"},{"l":"pickle.dumps(obj) - bytes","p":["Return the pickled representation of an object as a bytes object."]},{"l":"pickle.loads(b: bytes)","p":["Return the unpickled object from a bytes object."]},{"l":"What can be pickled and unpickled?","p":["The following types can be pickled:","None, True, and False;","integers, floating-point numbers;","strings, bytes;","tuples, lists, sets, and dictionaries containing only picklable objects;","functions (user-defined) accessible from the top level of a module (using def, not lambda);","classes accessible from the top level of a module;","instances of such classes","The following magic methods are available:","__getnewargs__","__getstate__","__setstate__","__reduce__"]}],[{"l":"pkpy","p":["Provide internal access to the pocketpy interpreter."]},{"l":"Source code"}],[{"l":"random"},{"l":"random.seed(a)","p":["Set the random seed."]},{"l":"random.random()","p":["Return a random float number in the range [0.0, 1.0)."]},{"l":"random.randint(a, b)","p":["Return a random integer in the range [a, b]."]},{"l":"random.uniform(a, b)","p":["Return a random float number in the range [a, b)."]},{"l":"random.choice(seq)","p":["Return a random element from a sequence."]},{"l":"random.shuffle(seq)","p":["Shuffle a sequence inplace."]},{"l":"random.choices(population, weights=None, k=1)","p":["Return a k sized list of elements chosen from the population with replacement."]}],[{"l":"sys"},{"l":"sys.version","p":["The version of pkpy."]},{"l":"sys.platform","p":["May be one of:","win32","linux","darwin","android","ios","emscripten"]},{"l":"sys.argv","p":["The command line arguments. Set by py_sys_setargv."]},{"l":"sys.setrecursionlimit(limit: int)","p":["Set the maximum depth of the Python interpreter stack to limit. This limit prevents infinite recursion from causing an overflow of the C stack and crashing the interpreter."]},{"l":"sys.getrecursionlimit() - int","p":["Return the current value of the recursion limit."]}],[{"l":"time"},{"l":"time.time()","p":["Returns the current time in seconds since the epoch as a floating point number."]},{"l":"time.sleep(secs)","p":["Suspend execution of the calling thread for the given number of seconds."]},{"l":"time.localtime()","p":["Returns the current struct time as a struct_time object."]}],[{"l":"traceback"},{"l":"traceback.print_exc() - None","p":["Print the last exception and its traceback."]},{"l":"traceback.format_exc() - str","p":["Return the last exception and its traceback as a string."]}],[{"l":"typing","p":["Placeholder module for type hints."]},{"l":"Source code"}],[{"l":"unicodedata"},{"l":"unicodedata.east_asian_width(char: str) - str","p":["Returns the East Asian width of a Unicode character. The width is one of the following values:","F: Fullwidth","H: Halfwidth","N: Neutral","Na: Narrow","W: Wide","A: Ambiguous"]}],[{"l":"vmath","p":["Provide vector math operations."]},{"l":"Source code"}],[{"l":"Application Guide","p":["Before starting, please read the Ideas page and choose a project you are interested in. Set up a C11 compiler, clone pocketpy sources from github and try to build. This helps you confirm that your skills and experience match the requirements of the project."]},{"l":"Build guide for beginners","p":["First, you need to install these tools:","Python(>= 3.8), I am sure you already have it.","A C11 compiler, such as GCC, Clang or MSVC. If you are on Linux, gcc is already installed. If you are on Windows, you can install Visual Studio with C/C++ development tools.","CMake(>= 3.10), a cross-platform build tool. You can use pip install cmake to install it.","Then, clone pocketpy sources from github and try to build:","If everything goes well, you will get a main executable ( main.exe on Windows) in the root directory of pocketpy. Simply run it and you will enter pocketpy's REPL."]},{"l":"Application guide","p":["Your need to send an email to blueloveth@foxmail.com with the following information:","A brief introduction about yourself, including the most related open sourced project you have worked on before. It is highly recommended to attach your Github profile link.","A technical proposal for the project you are interested in working on, including:","Your understanding of the project.","The technical approach/architecture you will adopt.","The challenges you might face and how you will overcome them.","A timeline for the project, including the milestones and deliverables.","Other information required by the Google Summer of Code program."]},{"l":"Coding style guide","p":["See Coding Style Guide."]},{"l":"Contact us","p":["If you have any questions, you can join our Discord or contact me via email. We are glad to help you with your application."]}],[{"l":"Project Ideas"},{"l":"VSCode plugin for debugging pocketpy applications","p":["Difficulty Level: 3/5 (Medium)","Skill: TypeScript; C","Project Length: Medium","Community users have reported that there is no convenient way to debug python applications interpreted by pocketpy. Fortunately, VSCode provides a mechanism of Debugger Extension that allows us to integrate pocketpy debugger into VSCode UI through Debug Adapter Protocol (DAP).","This project aims to develop a VSCode plugin like Python Debugger, which implements DAP for pocketpy. With this plugin, users can launch their pocketpy applications in VSCode with breakpoints, call stacks, and variable inspection. Students with experience in TypeScript will be helpful for this project."]},{"l":"Develop math operators for cTensor library","p":["Difficulty Level: 4/5 (Hard)","Skill: C; Further Mathematics","Project Length: Small or Medium","pocketpy is providing a tensor library cTensor for users who want to integrate neural networks into their applications. cTensor implements automatic differentiation and dynamic compute graph. It allows users to train and deploy neural networks on client-side devices like mobile phones and microcontrollers (e.g. ESP32-C3). We have a runable prototype located at pocketpy/cTensor. But math operators have not been implemented yet.","In this project, students will develop forward and backward math operators, as well as basic neural network layers and optimizers (e.g. SGD, Adam). The project is written in C11. We expect students to have a good understanding of further mathematics and C programming.","This year we also accept custom project ideas. If you are not interested in the above, you can propose your own idea and contact me via blueloveth@foxmail.com. We will discuss the feasibility and mentorship for your idea."]}],[{"l":"Application Guide","p":["Before starting, please read the Ideas page and choose a project you are interested in. Set up a C++ compiler, clone pocketpy sources from github and try to build. This helps you confirm that your skills and experience match the requirements of the project."]},{"l":"Build guide for beginners","p":["First, you need to install these tools:","Python(>= 3.8), I am sure you already have it.","A C++ compiler, such as GCC, Clang or MSVC. If you are on Linux, gcc and g++ are already installed. If you are on Windows, you can install Visual Studio with C++ development tools.","CMake(>= 3.10), a cross-platform build tool. You can use pip install cmake to install it.","Then, clone pocketpy sources from github and try to build:","If everything goes well, you will get a main executable ( main.exe on Windows) in the root directory of pocketpy. Simply run it and you will enter pocketpy's REPL."]},{"l":"Application guide","p":["Your need to send an email to blueloveth@foxmail.com with the following information:","A brief introduction about yourself, including the most related open sourced project you have worked on before. It is highly recommended to attach your Github profile link.","A technical proposal for the project you are interested in working on, including:","Your understanding of the project.","The technical approach/architecture you will adopt.","The challenges you might face and how you will overcome them.","A timeline for the project, including the milestones and deliverables.","Other information required by the Google Summer of Code program."]},{"l":"Coding style guide","p":["See Coding Style Guide."]},{"l":"Contact us","p":["If you have any questions, you can join our Discord or contact me via email. We are glad to help you with your application."]}],[{"l":"Project Ideas"},{"l":"Implement pybind11 for bindings","p":["Difficulty Level: 5/5 (Hard)","Skill: Advanced C++ with metaprogramming; Python","Project Length: Medium (175 hours)","https://summerofcode.withgoogle.com/archive/2024/projects/Ji2Mi97o","pocketpy has provided a low-level API for creating bindings. It is fast, lightweight and easy to debug. However, it still requires a lot of boilerplate code to create bindings for complex C++ classes. The community has long expected a high-level API for creating bindings.","pybind11 is the most popular C++ library for creating Python bindings for CPython. A bunch of Python libraries are using it. pybind11 adopts a template metaprogramming approach to automatically generate bindings for C++ classes.","Our goal is to introduce a pybind11 compatible solution to pocketpy as an alternative way to create bindings for functions and classes. You can use C++17 features to implement it, instead of C++ 11 used in pybind11.","See https://github.com/pocketpy/pocketpy/issues/216 for more details."]},{"l":"Add numpy module","p":["Difficulty Level: 4/5 (Intermediate)","Skill: Intermediate C++; Python; Linear Algebra","Project Length: Medium (175 hours)","https://summerofcode.withgoogle.com/archive/2024/projects/sJLuASSP","Though pocketpy is designed for game scripting, some people are using it for scientific computing. It would be nice to have a numpy module in pocketpy.","numpy is a huge project. Our goal is to implement a most commonly used subset of numpy in pocketpy. You can mix C++ and Python code to simplify the overall workloads.","See https://github.com/pocketpy/pocketpy/issues/202 for more details."]}],[{"l":"Coding Style Guide"},{"l":"Indentation","p":["Use four spaces for indentation. Do not use TAB."]},{"l":"Strings"},{"l":"Docstrings","p":["Always use triple quotes for docstrings.","Use natural language to describe the function's purpose. Do not enumerate each parameter and return value."]},{"l":"Spaces"},{"l":"Naming Conventions","p":["Classes: CapitalizedWords","Functions and variables: lower_case_with_underscores","Constants and enums: UPPER_CASE_WITH_UNDERSCORES or CapitalizedWords","Anonymous ordered variables: _0, _1, _2","Discarded variables: _","Some standard library functions: lowercase","Here are some commonly used naming conventions:","self: The first parameter of an instance method","cls: The first parameter of class methods and __new__"]},{"l":"Using Abbreviations","p":["Use abbreviations only for temporary variables and internal implementations.","Abbreviations should be well-established, include key syllables of the original word, and be immediately recognizable.","context-> ctx(✔)","temporary-> tmp(✔)","distribution-> dist(✔)","visited-> vis(❌)"]},{"l":"Using Precise Terminology","p":["Naming should convey precise meanings, especially when multiple synonyms exist.","For example, count, size, and length all relate to quantity, but they have different nuances:","count: Represents a counted value","length: Represents the number of elements in a container","size: Represents the byte size of an object"]},{"l":"Using Professional Terminology","p":["For item quantities in a game: quantity is better than item_count","For grid counts: area(meaning surface area) is better than grid_count"]},{"l":"Avoiding Built-in Names"},{"l":"Internal Functions and Classes","p":["Use a single underscore _ as a prefix for internal functions. Never use a double underscore __(except for magic methods)."]},{"l":"Importing Modules","p":["Import standard library modules first.","Then import third-party dependencies.","Finally, import project-specific modules."]},{"l":"Coding Practices","p":["Use is not when checking for None. Do not explicitly compare with True or False.","The if statement implicitly calls bool(), so it can be used to check if a container is empty."]},{"l":"References","p":["PEP 8 Style Guide for Python Code"]}],[{"l":"Performance","p":["Currently, pkpy is as fast as cpython 3.9. Performance results for cpython 3.9 are applicable to for pkpy.","Here is a benchmark result of v1.2.6. Files are located in benchmarks/."]},{"l":"win32 64-bit cpy39"},{"l":"linux 64-bit cpy38"},{"l":"linux 32-bit cpy39","p":["See actions/runs."]},{"l":"Primes benchmarks","p":["0.104s ■□□□□□□□□□□□□□□□","1.2.7","1.576s ■■■■■■■■■□□□□□□□","2.385s ■■■■■■■■■■■■■□□□","2.871s ■■■■■■■■■■■■■■■■","3.8.10","5.3.3","benchmarks/primes.cpp","benchmarks/primes.lua","benchmarks/primes.py","c++","cpython","file","gnu++ 11","lua","name","pkpy","These are the results of the primes benchmark on Intel i5-12400F, WSL (Ubuntu 20.04 LTS).","time","version"]}],[{"l":"License","p":["pkpy is licensed under the MIT License."]}]]