[Mesa-dev] [PATCH 1.2/8] spirv: Generate spirv_info.c
Dylan Baker
dylan at pnwbakers.com
Tue Jul 18 20:42:40 UTC 2017
Quoting Jason Ekstrand (2017-07-17 10:42:05)
> Generally available things tend to be painful in Python because you have to set
> the python path if you ever want to import anything that isn't in your
> directory. That doesn't mean we shouldn't do it, just that the pain may be too
> high. Also, having a copyright block at the top of the file as suggested means
> that the python file still has a copyright block.
I agree about the pain of PYTHONPATH, but putting an assignment before imports
is a really, really, really, really bad idea. In python import is an overloaded
keyword, it does two related things. It does the familiar "give me module <X> in
my namespace", but it also can change the semantics of the language. That's what
"from __future__ import <x>" does, and one of the things you can change that way
is whether a string is a unicode or a bytearray in python2 (they default to
bytearrays in python2, but unicode in python3), which is something we'll want to
toggle if hybridize for python2 and 3. What would happen in this file now if we
added "from __future__ import unicode_literals" is that the COPYRIGHT would
visually look like a unicode object, but would actually be a bytearray, while
the rest of the naked strings in the file would be unicode.
What would actually be much easier, is putting the function in a mako file and
loading that, mako has filesystem based loader for such things, and injecting
mako into mako templates is pretty easy. I'll send a patch for that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170718/892d4267/attachment.sig>
More information about the mesa-dev
mailing list