This question has an easy answer - can you possibly tell the difference?
Ok, I'm obviously being silly here, but sure you can:
dis.dis(raise TypeError())
0 114 26977
3 1158293
6 IMPORT_STAR
7 SETUP_EXCEPT25968 (to 25978)
Whoa. That's very peculiar looking bytecode. Is dis.dis behaving as
it should here?
BTW, I think you want 'raise TypeError', not 'raise TypeError()'.
Yep, that's embarrassing. I was being lazy: I was expecting different
bytecodes, and I got it ... so I apparently didn't bother to actually
But you would be taking a module that will compile and making it uncompilable.
You're absolutely right, and since I definitely *don't* think that the
program raise TypeError should cause a CompileError, you could say
it's safer to have a simple rule like vaild syntax = will compile
-- it's
1/0 is much faster to type than raise SomeError and serves the same
purpose sometimes for debugging purposes. Let's not forget that not
all code is written for eternity :)
Doesn't raise do the same thing for just two extra characters?
I agree that not all code lives forever -- but I bet we
To test that adding a string to an integer raises TypeError at
runtime. That is, something along the lines of:
with self.assertRaises(TypeError):
1 + 1
Well, this would just mean the test suite would have to change -- that
test would become something like
with
for a college project, I proposed to create a compiler for python. I've
read something about it and maybe I saw that made a bad choice. I hear
everyone's opinion respond.
I don't think everyone thinks this is a bad idea -- for instance,
those of us working on Cython [1], which is itself a
I hate to remind you but Cython is *not* python. It does not even plan
to support all of the parts which are considered python semantics
(like tracebacks and frames).
It's true -- we basically compile to C + the Python/C API, depending
on CPython being around for runtime support, and I don't
Done. The diff is at
http://codereview.appspot.com/186247/diff2/5014:8003/7002. I listed
Cython, Shedskin and a bunch of other alternatives to pure CPython.
Some of that information is based on conversations I've had with the
respective developers, and I'd appreciate corrections if I'm out of