Rewriting built-in types

7 views
Skip to first unread message

Pierre Quentel

unread,
Jan 12, 2026, 4:51:18 PM (12 hours ago) Jan 12
to brython
Hi all,

The last commit in the master branch is more than 2 months old, which is an all-time record in the 13-year history of Brython !

But that doesn't mean I'm less active on the project, on the contrary: I am working like mad on a new branch called "tp_methods_2025", which consists in a total rewriting of the built-in classes implementation.

The main reason was to make the code for attribute resolution as straightforward as in CPython, just a few lines of code for object and type __getattribute__ methods, whereas the current code in Brython (object.__getattribute__ in py_object.js and type.__getattribute__ in py_type.js) is extremely long and hard to maintain. Fixing bugs such as the ones detected by Djoume Salvetti on unittest.mock meant adding even more code for special cases.

The new version will be much closer to the code of the CPython implementation. For instance, types are now implemented as Javascript object with (more or less) the same name as in CPython (tp_name, tp_getattro, etc). Methods are also implemented with the same type as in CPython (wrapper_descriptor, method_wrapper, etc.).

For the first time today the first test in the built-in test suite passes completely. Making all the tests pass will still take a few weeks, maybe months. I will keep you updated from time to time.

Best wishes,
Pierre

ben levitt

unread,
Jan 12, 2026, 5:19:28 PM (11 hours ago) Jan 12
to bry...@googlegroups.com
Thank you Pierre!

I look forward to testing out your updated code whenever you're ready for more testing. 

Happy New Year,
Ben

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/brython/19458fae-945a-46b1-8cb4-14a8e0899ec4n%40googlegroups.com.

Djoume Salvetti

unread,
Jan 12, 2026, 5:58:35 PM (11 hours ago) Jan 12
to ben levitt, bry...@googlegroups.com
Sounds very exciting! Likewise happy to test whenever ready to provide feedback :-)

-- 
  Djoume Salvetti

Reply all
Reply to author
Forward
0 new messages