firedrakeproject/firedrake — pull request #416 by wence- (2014-12-05 12:03:21+00:00)
Title: Dispatch on C/Python Expressions based on type

It's not safe to check for a .code attribute in an Expression and assume
it's a "C kernel" one, since the user may have subclassed expression and
called the superclass __init__ method. Instead, check the type.