Specifications
4. SNAPpy versus Python
Here are more details about SNAPpy, with emphasis on the differences between SNAPpy and Python.
Modules
SNAPpy supports import of user-defined as well as standard predefined Python source library
modules.
from module import * # Supported
import module # Not supported
Variables
Local and Global variables are supported. On RAM-constrained devices, SNAPpy images are
typically limited to 64 system globals and 64 concurrent locals. Per-platform values are given in the
back of this document.
Functions
Up to 255 “public” functions may be defined. These are remotely callable using the SNAP RPC
protocol.
Non-public functions (prefixed with underscore) are limited only by the size of FLASH memory.
Data Types
SNAPpy supports the following fundamental Python data types:
• NoneType – None is a valid value
• int – An int is a signed 16-bit integer, -32768 through 32767. 32767 + 1 = -32768.
• bool – A bool has a value of either True or False.
• string – A static string has a maximum size of 255 bytes. If you assign a literal to a string when a
function is created, this is the size limit that will be applied. However if you assign a value to a
string while a script is running, or attempt to reassign a value to a string declared outside a
function, SNAPpy uses a different collection of string buffers, and the maximum length of the
string will be determined by the platform on which SNAP is running. See the platform-specific
parameters in Section 10 for more details. (Note – built-in functions slice/concat/rpc enforce
smaller limits on what they can do with strings.)
• tuple – A tuple is a read-only container of other data types, e.g., (1,'A',True). SNAPpy tuples must
be global in scope and cannot be used outside the scope of a local script. You cannot pass them as
parameters in RPC calls to other nodes. You may nest tuples, however there are restrictions on the
printing of nested tuples. (See the details about printing, below.)
• function – A function is a user-defined subroutine invoked from elsewhere in your script, or by
RPC call from another node.
SNAPpy currently does not support the following common Python types, so they cannot be used in
SNAPpy scripts. They can still be used in Portal scripts.
• float – A float is a floating-point number, with a decimal part.
Page 22 of 202 SNAP Reference Manual Document Number 600-0007K