TCC support, etc

59 views
Skip to first unread message

Taillon

unread,
Feb 14, 2011, 1:46:59 PM2/14/11
to tinypy
Hi,

I found TInyPy several weeks ago, and started playing with 1.1, first,
and now with 1.2+SVN+Panda.
https://github.com/HarryR/tinypy-panda/blob/master/CHANGES.txt

I could build TinyPy with TCC by changing tp.h and builtins.c a bit.
With TCC , compiling is A LOT faster than gcc (compared to mingw on
Windows)
And the executable is smaller. But it may run a bit slower.

So far, I found missing regexpr.h, pathed regexpre.c, thus re, math,
and random modules compile and pass the test. (I haven't tested
pygame, yet.)

Also, I added command line options to TinyPy so that we can use -c
option like Python, -b option to compile can save .tpc but don't run
it, use .tpc instead of compiling .py if it's present and newer
than .py, and save the tpc when we run .py, etc.

I've also added some builtin functions like exit(), chdir(), getcwd(),
etc.

And I am working of setup.py so that we can build tinypy without
python.
It means we only need tcc and tinypy to build tinypy and it can be
interesting for some people wholike to have small development package.

Now, I'm chasing the issue around the "Stack overflow" error.
It doesn't show correct error message when TInyPy runs out of
registers (defined by #define TP_REGS in tp.h).

If anyone is interested in these changes, let me know.



Tim Cas

unread,
Feb 14, 2011, 4:02:58 PM2/14/11
to tin...@googlegroups.com
Well, I'm sort of a de-facto maintainer since everyone else lost interest...

I've been thinking of rewriting the project to completely remove the Python files for parsing and such, because I simply can't wrap my head around them; plus, the codebase is riddled with bugs.

So yeah, I am interested in the changes, but I won't be able to do much about them since I can't really wrap my head around the codebase.




--
You received this message because you are subscribed to the Google Groups "tinypy" group.
To post to this group, send email to tin...@googlegroups.com.
To unsubscribe from this group, send email to tinypy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tinypy?hl=en.


Phil Hassey

unread,
Feb 14, 2011, 9:46:37 PM2/14/11
to tin...@googlegroups.com
I also sometimes think about re-writing it again from another angle.  But I've been far to busy to really do that.  I might do something sometime, but I really have no idea.

I'd say if you or anyone is really wanting to do this, just set up a branch in svn and have at and see where it takes you.

The most important thing is that you be sure to develop the code with lots of automated tests and all that.  (Maybe using some of the test cases that tinypy already has .. though some of the later ones where it strays further from CPython could certainly be discarded.)

Cheers!
-Phil

--- On Mon, 2/14/11, Tim Cas <darku...@gmail.com> wrote:

Tim Cas

unread,
Feb 15, 2011, 2:23:05 AM2/15/11
to tin...@googlegroups.com
I also have some of my own ideas regarding features to add -- for example, I want to add tail call optimization (to support tail recursion!), it would increase the size of the interpreter a bit, but the benefits are enormous!

This means that the following would *never* result in a stack overflow (the number may still overflow, but that's a different story):

# tail-recursive implementation of the factorial function (a typical recursion example!)
def factorial(n, acc = 1):
if n == 0:
return acc
return factorial(n - 1, n * acc)

I'll make another thread regarding this, but right now, I have to go (univ stuff)... I hope I remember today afternoon, if not someone remind me to create the thread please!

Taillon

unread,
Feb 15, 2011, 10:40:58 AM2/15/11
to tinypy
Hi Tim and Phil,

Maybe I can make a branch if I have the access to SVN.
Or I can send the source to Tim, id preferred.

Later, I would make a stand alone package with tinypy and tcc so that
people without gcc/vs/etc can staet playing/toying with it, very
easily especially on win platform).
It may bring more people in (for rewriting/debugging/enhancing/etc).

Anyway, I'll continue and finish the modification of setup.py so that
it can be run with both python and tinypy, and hunt down some bugs so
that tinypy would terminate gracefully when all regs are used up.
It's around tp_raise and tp_handle, but I don;t yet understand how/why
things are done in certain way.


As for the tail recursion, please do it. :)
I guess it can be done in encode.py (or with parse.py)

I have other ideas like tinypy (byte code) to c translator, saving
and loading frames (converting pointers), debugger for tinypy (using
bytecode assembler and disassembler), and so on.
But I guess I would make socket module module before any of these.

If stability, thread/coroutin, ffi/dllcall, and a few other things are
done, I think whole a lot more people would actually use it for many
things.

Tim Cas

unread,
Feb 15, 2011, 4:08:41 PM2/15/11
to tin...@googlegroups.com
Please continue this discussion in the main recode/rework thread that I have created.


--
Reply all
Reply to author
Forward
0 new messages