6.1. PikaStdLib standard library

PikaStdLib is a built-in library of PikaPython, which must be installed. It includes memory checking tools and system objects.

6.1.1. Install

Add the dependency of PikaStdLib to requestment.txt. The version number of PikaStdLib should be the same as the version number of the kernel.

PikaStdLib

Run pikaPackage.exe

6.1.2. import

Add in main.py

#main.py
import PikaStdLib

6.1.3. class MemChecker()

MemChecker provides PikaPython’s memory monitoring capabilities. Can be used to view memory usage and check for memory leaks.

def max(self):

Print the maximum memory footprint value.

def now(self):

Print the current memory usage value.

def getMax(self)->float:

Returns the largest memory footprint

def getNow(self)->float

Returns the current memory usage value.

def resetMax(self)

Reset the maximum memory usage value Example:

# main.py
import PikaStdLib
mem = PikaStdLib.MemChecker()
print('mem used max:')
mem.max()
print('mem used now:')
mem.resetMax()
print('mem used max:' + str(mem.getMax()))
print('mem used now:' + str(mem.getNow()))

6.1.4. class SysObj()

SysObj is used to provide built-in functions, the scripts executed in main.py are executed by the root object, and the root object is created by the SysObj class, so the methods in the SysObj class are built-in functions.

def type(arg: any):

print variable type

def remove(argPath: str):

To remove a variable/object, use a string when removing, e.g. remove('a').

def int(arg: any) -> int:
def float(arg: any) -> float:
def str(arg: any) -> str:

for type conversion

def print(arg:any):

Inherited from BaseObj, provides print output. Formatted output is not currently supported.