Git Product home page Git Product logo

peep's Introduction

Peep provides simple but useful tools for Python development.

It includes a reloading function runner that can minimize your edit-compile-run cycle and some tools for estimating deep memory usage of objects.

The reloading function runner was inspired by Bret Victor's talk, "Inventing on Principle". Automatic reexecution is the first step, and peep may grow to include more functionality from that talk.

Peep is a small API and has no dependencies outside of the Python standard library. It works with Python 2.6 and 2.7.

Reporting memory usage

It supports getting memory usage (in bytes) of object trees:

>>> obj = {"foo": "bar", "baz": ("quux", "quuux", "quuuux")}
>>> peep.mem_usage(obj)
606

The same information, broken down by object type:

>>> obj = {"foo": "bar", "baz": ("quux", "quuux", "quuuux")}
>>> peep.mem_usage_by_type(obj)
{<type 'dict'>: 280, <type 'str'>: 246, <type 'tuple'>: 80}

Reloading function runner

The reloading function runner takes a callable that accepts no arguments and will not be reloaded itself. This means you can't pass a reference to an already compiled function; use a partial function or a lambda expression.

With foo.py:

def run():
    return "This is returned from foo.run()"
>>> import foo
>>> peep.call_on_change(lambda: foo.run())
======== 1365429591.13
This is returned from foo.run()

[ modify foo.py ]

=== reloading <module 'foo' from 'foo.py'>
======== 1365429594.64
This is newly returned from foo.run()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.