npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bryntime

v2.3.0

Published

The Brython runtime for JavaScript frameworks

Readme

Bryntime

The Brython runtime for JavaScript frameworks.

Brython runs Python in the browser. Bryntime is what a JavaScript framework, or a page with none, needs on top of it to use Python's values as its own: to read them, to write them, to call them, and to know when they change.

Install it from npm:

npm install bryntime
import { viewOf, track, pyExport } from 'bryntime';

const list = viewOf(todos); // a Python list of dicts, read as an Array of objects
list[1].done = true; // written into the Python dict, as `todos[1]["done"] = True`
track(todos, render); // told of every change, Python's `todos.append(…)` included
const add = pyExport(addTodo); // a Python function JavaScript calls

What it does

Python and JavaScript do not see a value the same way. A dict, a set and an instance are Brython objects to JavaScript, None is an object rather than undefined, and a mutation made in Python, rows.append(x), d["k"] = v, point.x += 1, happens inside the engine, where no framework sees it. Bryntime closes each gap:

  • Live views (viewOf): a list read as an Array, a dict and an instance as objects, a set as a Set. Reads are live, and JavaScript's writes are Python's writes. A container of the author's class, class Rows(list), shows its properties and methods too, as a subclass of Array shows its getters. An iterable made as it goes, a generator, map, a range, is read as the list list() makes of it, made at the first read of what it holds; until then Python reads it back as the iterable itself, untouched (listedNow makes the list at once). A value a framework made of data it had handed out as its own proxy is handed as that proxy from then on, by every door, and read back as the value (handedAs), so a page keeps the object it read.
  • Change tracking (track, follow): a subscriber is told of every change Python makes to a value or to anything inside it, whichever operation makes it, and of nothing else: a read, a copy, or a write of the value already held tells nobody, as a framework's own state does. What no tracking follows, Python's reads of JavaScript's own object, is counted while a framework weighs an expression (weighingReads, javascriptReads), so that it reads such an expression again at each render, as it reads its own.
  • Copies under one rule (plainData, pyData): None is JavaScript's undefined at every door and null in JSON alone, javascript.NULL is null, and two keys JavaScript cannot tell apart are refused, not merged.
  • Calls (pyExport): a Python function JavaScript calls, and JavaScript functions Python calls, their arguments and results crossing both ways.
  • Errors (pyError, refused): what Python raises reaches JavaScript with its message and its stack, and what Bryntime refuses is signed with the framework's name.
  • Modules (bind, withNamespace, runningLine, runningModule): a Python module whose globals are a framework's states, each name an accessor over one of them, with globals(), del and import behaving as Python's, and the line of its own body a write or a call comes from.
  • A template's dot (readAttr, writeAttr, writeItem): pep.title in a template reads the attribute, or the key of a dict failing that, as Jinja's dot does, and a write lands where that read comes from; one rule for every framework's template, Svelthon's and Vuython's.
  • Another process (pickled, unpickled): pickle's protocol written in JavaScript, for a framework that carries a value from its server to its browser: a structure its serialiser writes, out of which comes the same value, its types, its sharing and its cycles, an instance rebuilt by its class's __reduce__, __getstate__, __setstate__ and __slots__, the items of a list's or a dict's subclass as its __iter__ or its items() hands them, a class or a function by its name; refused where pickle refuses. unpickled(…, { restricted: true }) reads what came from a side the reader does not trust, values alone. roundTrip does both at once: the structure that crosses, and the copy the other end rebuilds of it, which a server's own page can read; with keep, the value itself where no copy could differ from it. A coroutine crosses as the promise of its result, which comes out a future Python awaits. An object a framework hands JavaScript in place of such a value, before it can be rebuilt, reads in Python as that value (standsForPython), wherever Python finds it, in a JavaScript array or object too, and so does one the framework made itself, which the host recognises when Python first meets it (readsAsPython).

The same value on the server and in the browser

A framework that renders a page on its server and again in the browser sends the page's data from one to the other, and both renders must read the same values. For JavaScript's values, its serialiser does that. For Python's, Bryntime has pickle:

import { pickled, unpickled } from 'bryntime';

const sent = pickled(data); // on the server, for the framework's own serialiser
const same = unpickled(sent); // in the browser: the same value

A tuple comes back a tuple, an int key an int, 1.0 a float, one object reached twice one object, a cycle a cycle, and an instance of a class an instance of it, rebuilt by its __reduce__ or its __setstate__. Nothing here is tied to one framework: Svelthon installs it in SvelteKit's transport, and any framework with a hook for its own types can do the same. What crosses and what is refused is the list under Another process above.

Two things do not come back by value. What pickle carries by reference: a class, a function, a builtin, and an object whose __reduce__ returns a string, a named singleton. Each is written as its module and its qualified name, which must reach that very object again (pickle's save_global); a local object, or one with no module, is refused. The reader finds it again by importing the module and walking the name, never through a dunder: the engine's own modules are refused, restricted: true refuses every reference, a host's refused names the modules the other side cannot import, and its missing is told of one the reader lacks. A reader with no engine cannot resolve a reference at all, and what it shows in its place is the host's choice. And the id() a default repr shows, which belongs to each process. Everything else, values, types, sharing and cycles, comes back equal.

A framework's side

A framework imports one entry, bryntime, and answers through host what only it knows: whether one of its states owns a value (owns), how it makes an object its state (adopt), its name (name), whether a reaction is running (reacting), whether a write would be refused (refuses), a subscription (subscriber), a read that follows nothing (untrack), whether an unbound name read at a line is an absence (absent), whether a module's namespace is read-only through globals() and its other doors (readOnlyNamespace), and what a value of its own crosses to JavaScript as, at every door (crossesAs): React's element for a t-string. With no host at all, every read is taken for a reaction's and nothing is refused, which is what a page with no framework wants.

import { host } from 'bryntime';

A compiler loads Brython's other half onto the same engine:

import 'bryntime';
import 'bryvend/compiler';

Demo

demo/ is a page with no framework and a to-do list held by a Python module: the tasks instances of a class, their tags a set, the filter a global. JavaScript renders them, ticks a box, stars a task and removes one by writing into Python's own values; Python adds a task, refuses an empty title with a ValueError the page shows, deletes the done ones and rebinds todos = []; and the page is told of each change, whichever side made it.

It is online at https://svelthon.github.io/bryntime/, deployed from main once the tests pass. Locally, it is served as it is, from the repository's root:

python3 -m http.server

then http://localhost:8000/demo/. The suite runs the same page, so the demo cannot drift from the API it shows.

The engine

Bryntime runs on Bryvend, its peer dependency: Brython's master and the repairs proposed there and not merged yet, one commit each, as an ES module. Bryvend's BRYTHON_FIX.md lists them all, with the edits made in the file itself, and the tests here hold each repair Bryntime rests on.

A page loads bryvend, the half without the parsing chain: 238 KB gzipped. A compiler adds the other half, bryvend/compiler.

What Bryntime asks of the engine, member by member, is in BRYTHON.md.

License

Copyright (C) 2026 Florent Gallaire [email protected]

Bryntime is licensed under the BSD 3-Clause License, the same license as Brython.