Skip to main content

A virtual stack machine that executes Python code based on instructions provided in a JSON file.

Project description

Overview

Sequence is a library that lets you build analysis tools that can be controlled by configuration files. This is useful when you want to define the logic for generating some sort of output, like data or an image, in a configuration file. This type of configuration file is called a sequence and it defines a sequence of operations that do something.

Under the hood, sequences are run by a virtual stack machine. A sequence is a list of operations, where an operation is either another sequence or a method. A method is a Python function that uses the @sequence.method decorator and methods provide basic functionality building blocks. Methods and sequences pass data to each other on the virtual machine's stack, via pushing, popping, and swapping data.

A sequence toolkit (STK) is a Python package that provides a suite of methods. The standard toolkit (built-in) is a suite of turing-complete methods that provide the backbone for scripting logic in sequences (e.g., if blocks, while loops, string formatting, data resources, etc.). Additional functionality can be added by installing additional toolkits.

About Stack Machines

If it isn't clear how operations pass data using the stack, a good way to get familiar with the concept is by playing around with an RPN calculator like this. Try calculating the hypotenuse of a triangle with side length of 3 and 4 using the Pythagorean Theorem (the answer is 3, Enter, X, Enter, 4, Enter, X, +, SQRT). Every button-press is equivalent to an operation in sequence.

The design of sequence took inspiration from these old RPN-style calculators as well as the FORTH programming language.

Installing sequence

Sequence can be install using pip. The basic install supports JSON.

$ pip install sequence-stk

It's often useful to be able to write comments and use multi-line strings in sequences. JSON5 and HSON are extensions of JSON that support these features. Additional configuration languages can be installed via the json5, and/ord hson extras.

$ pip install "sequence[json5,hson]"

If you are developing an STK, the dev and docs extras install the requirements for running tests and building documentation.

$ pip install "sequence[dev,docs]"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sequence-stk-0.7.2.tar.gz (38.7 kB view details)

Uploaded Source

Built Distribution

sequence_stk-0.7.2-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file sequence-stk-0.7.2.tar.gz.

File metadata

  • Download URL: sequence-stk-0.7.2.tar.gz
  • Upload date:
  • Size: 38.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for sequence-stk-0.7.2.tar.gz
Algorithm Hash digest
SHA256 0771ac0c2d16ad47cc83ebc279010ec19ef83fc603665da69290d5ddd4283911
MD5 832ebd9c8ab136c23eb2d8818f9afa3c
BLAKE2b-256 16a0766a85322e12dfce36a0568bc4d8a91d12435ecbce03cf4a4d20aca8596f

See more details on using hashes here.

File details

Details for the file sequence_stk-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: sequence_stk-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for sequence_stk-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 630847f47ce36eba011a831c1e683d6105984591bae525b230fece7117ed41d3
MD5 50889a4810b71e6ee3be166c51f39bc4
BLAKE2b-256 afb977a58433b8864d7610e5780731e00ca849a86b21cb4e9c176eadc95c8b55

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page