Guppy | A fish swimming in Python |
Heapy | Heap Analysis Toolset |
GSL | Guppy Specification Language |
Documentation | |
Download | |
Credits | |
Contact |
This is the home page for Guppy 3 , a programming environment providing object and heap memory sizing, profiling and analysis. It includes a prototypical specification language that can be used to formally specify aspects of Python programs and generate tests and documentation from a common source.
Guppy 3 is a fork of Guppy-PE , created by Sverker Nilsson for Python 2.
Guppy is an umbrella package combining Heapy and GSL with support utilities such as the Glue module that keeps things together.
The name guppy was chosen because Nilsson found it in a backward-dictionary as a word ending with py and he thought it was cute enough and that it would not so likely conflict with some other package name. It was to be a general name since all kinds of packages should fit under this top level name.
The aim of Heapy is to support debugging and optimization regarding memory related issues in Python programs.
Such issues can make a program use too much memory, making it slow by itself as well as slowing down an entire server, or it may fail to run at all in a limited memory device such as a mobile phone.
The primary motivation for Heapy is that there has been a lack of support for the programmer to get information about the memory usage in Python programs. Heapy is an attempt to improve this situation. A project with a similar intent is PySizer.
The problem situation has a number of aspects, which Nilsson think can be characterised, for example, as follows.
As Heapy has evolved, with considerations like this in mind, it currently provides the following features.
Heapy has been used during development of itself and of the other parts of Guppy. It has been used to tell how much memory the parts of compound objects use, to see what could be worthwhile to optimize. It was used to find a memory leak in the Heapy profile browser, and to find out the cause, which as far as Nilsson can tell was due to a bug in a library routine which he have reported.
The Guppy Specification Language is an evolving specification language. Nilsson started experimenting with this language because he felt the need to have a way to specify documentation and tests from the same source. GSL can describe aspects of a system, especially its API, in a way that can be automatically converted to tests as well as to documents. The documents generated have a formal structure for describing the formal aspects of the specification, complemented with descriptive text from the same source documents. A language that is similar in intent is the Assertion Definition Language .
Specifications written in GSL can be used for:
Documents are generated from a combination of formally described aspects and descriptive text. The formal aspects include specifications of attributes and methods and their parameters and return values. The descriptive text is written together with the formal specifications. It can include HTML tags and attributes, specified in the GSL dotted tree format. Output modules can convert from the GSL form to formats such as HTML or Latex.
The tests generated can check the formal aspects of the specification against an implementation. It can test whether objects have the promised attributes, and then if the kind of attribute is specified it is tested again and so on. Methods are checked to see if they can be called with the forms of parameters specified. The return value can then be checked up to some limit of recursion.
A specification can be compared to a previous specification, to tell according to formalized rules whether or not the new one is backwards compatible with the old one, and if not, in what way they differ. For example, according to such rules, an attribute or parameter type can be added to a specification, but it can not be removed. The idea is that all tests possibly generated from the old specification should still succeed with objects conforming to the new specification. -- A program could likely compare specifications for compatibility automatically, but this is not yet implemented.
GSL has been used to generate the documentation for this Guppy distribution. Some part of the specification has been checked against the implementation using the generated tests, which did reveal some discrepancies that were subsequently corrected.
The documents generated by GSL use a formal syntax to describe parameter modes. This document contains examples of such parameter descriptions and explains what they mean.
Some documentation is included with the source code distribution and can also be browsed here via the following links.
Getting started with Heapy | An example of how to get started with Heapy | |||
Document example | Explains the meaning of some aspects of the documents. | |||
Guppy | Specification of guppy
, the top level module.
| |||
Profile Browser | How to use the graphical heap profile browser. | |||
Screenshot | Example showing the graphical heap profile browser in action. | |||
GSL | The Guppy Specification Language. | |||
heapyc | Specification of the heapyc extension module. Note that this is an internal interface and may be subject to change. | |||
sets | Specification of the interface to the setsc extension module which contains bitsets and nodesets. | |||
The following documentation is not included with the source code.
heapy-thesis.pdf | The master's thesis, "Heapy: A Memory Profiler and Debugger for Python", which presents background, design, implementation, rationale and some use cases for Heapy (version 0.1). | |||
Metadata and Abstract | Published at Linköping University Electronic Press. | |||
heapy-presentation.pdf | Slides from the presentation. | |||
Thanks to all that have written about Heapy on various blogs. Nilsson and I think the following links may be especially useful to get started. More tips are very welcome!
The latest version is in the git repository.
To check out the latest revision, you can do:
git clone https://github.com/zhuyifei1999/guppy3.git guppy