Pyxa Environment

Pyxa is a special subset of Python which is highly optimized for security and privacy. The syntax of the language is not modified from Python2.7. But, the runtime semantics is slightly different.

Runtime Environment

Built-in Data Structures

dict, set, list, tuple are all supported.

Global Reference

In order to use global references, you have to define your variable like this:

a = "my value"
global a
def myFunc():

Global references have to be explicitly declared. You can also do this:

a = "my value"
def myFunc():
    global a


Dynamic imports are not supported since the tService only supports single file mode in the devnet. Besides that, the developer can only import the supported libraries mentioned below.

Warning: Importing an unsupported module will cause the a run-time error.

Return Size

In the devnet, each tService request and response cannot contain more than 8KB of data in the "data" section. For example:

def myFunc():
    response.add("8KB OF DATA")

Helper Functions

global h
def h():
    return h2()

global h2
def h2():
    return "h2 called"    

def f():

Helper functions also need to obey the global reference rules.

Generator and For Loops

global gen
def gen():
    yield 1
    yield 2
    for x in xrange(3):
        yield x

def f():
    response.add(str(list(gen())))  # [1, 2, 0, 1, 2]

Supported Libraries

On the Devnet, Pyxa supports a subset of standard Python libraries and several additional libraries.

import math         #
import cmath        #
import collections  # same as collections,
import itertools    #
import array        #
import binascii     #, base64 encode/decode included
import json         # Derived from pypyjson, code releasing soon
import md5          #
import pyaes        #
import sha          #
import sha256       #
import sha3         #