Annotate observed types in a Python program
2008-06-18 12:22:02
Neat script I wrote for a friend to
annotate a Python script with the types
observed during a run of the program. Usage:
python -m annotype test.py
With this script:
def foo(bar, baz):
pass
foo(1, 'a')
foo(2, 3)
Outputs 'out_annotype/test.py' with:
def foo(bar, baz):
# [annotype] bar: int
# [annotype] baz: str, int
pass
foo(1, 'a')
foo(2, 3)
Hopefully useful for discovering usage of undocumented APIs.
Python, meet Vista/64
2008-05-09 00:06:24
Finally bought a copy of Vista/64 today. First Python experience:
C:\Python25>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:17:27) [MSC v.1400 64 bit (AMD64)]
on win32
Type "help", "copyright", "credits" or
"license" for more information.
>>> import sys
>>> sys.platform
'win32'
>>>
Sigh. And then,
>>> import ctypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named ctypes
>>>
Um, should Python even be distributed as version "2.5.2" on this
platform if parts of the standard library are missing?
(Oh, and Vista is pretty, except when the "Press this button to keep doing
what you're doing" dialog pops up, because it always seems to blank the
screen first -- possibly disabling Aero temporarily?).
Compiling for G3 on OS X 10.5
2008-04-18 00:03:46
It took me a long time to figure this out. By default gcc on Leopard compiles
for OS X 10.5 only. When cross-compiling to PowerPC, the default target is
actually certain G4 models. The magic options for G3's and OS X 10.3.9 (it looks
like you can't compile for earlier versions any more) and later:
-arch ppc
-isysroot /Developer/SDKs/MacOSX10.4u.sdk
-mmacosx-version-min=10.3.9
-force_cpusubtype_ALL
(both linker and compiler). Use
otool -hv xyz.dylib
to check that a Mach-O file is for the target you expect ("ppc" not
"ppc7740" etc), and
lipo -info xyz.dylib
to check the contents of a universal binary.
pyglet download statistics
2008-03-23 22:44:21
I felt charty this evening, and this is what happened:

That's a breakdown by release and distribution of pyglet, from 1.0 alpha 1
through to 1.1 alpha 1 (alpha 2, released hours ago, doesn't yet rate on this
chart).
Interesting to note: the eggs are popular for release, but not development. The
only reason they're featured in 1.0 alpha 1 is that they were actually linked
from the download page then. (Now people are only likely to grab an egg if
they're using easy_install from the command line).
The Windows installer is quite the popular, which makes me glad I spent so much
time on it. (I'm not making installers available for 1.1 alpha releases).
Here are the download stats for the packages including documentation/examples.

Looks to me like the number of developers isn't really increasing, but perhaps
those developers are testing on more machines, and perhaps there are some runtime
installations being made on non-developer machines. Or maybe there are more
developers but they're happy to use old or online documentation.
There are currently 271 pyglet-users members (or 269, depending on which counter
on the same page you read).
Play with your peas
2008-02-12 23:40:29
Danc of
Lost Garden has posted a new
game challenge that includes a design and
sprites.
Under the cover of "testing the latest pyglet features" (but really
for the hell of it) I made a quick stab at it last night and today.

You can play with
peas-1.zip, you'll need pyglet trunk r1760. It's nothing like
complete: you can place and remove blocks, and the peas will A* themselves up to
the higest point and "ninja" themselves off it; but the scoring, flag
raising and deathliness is missing.
The physics seems quite stable (using Verlet integration with a fixed timestep),
but the contact constraints on the corners are doubled, which is why the peas
seem to gain energy when bouncing off walls.
I made a botch of the AI movement: every specific combination of blocks that can
be moved between has to be listed (e.g., left side of standard block to top side
of left ramp, ...). I didn't get around to listing them all, so the peas will
refuse to move around certain objects that seem trivial. If you just place
standard blocks they'll do fine. I would rewrite this to something a bit
cleverer if I was going to continue any further...
...which I don't think I will. These peas are cute, but I don't think the game
is going to turn out all that great, relative to the effort required to fix up
the AI and physics.
I was able to pick up a few pyglet bugs writing this. The sprite module seems
(now) pretty solid and absolutely useful for this kind of game -- I didn't need
to use pyglet.gl at all.
J Kenneth King writes:
Neat little script. Thanks for sharing. :)