Re: [Cython] [cython-users] call for contribution: PEP 498 - Literal String Interpolation
I would be interested in doing this, although I haven't previously worked on Cython itself. I'll start looking into it over the weekend. 2015-09-09 7:35 GMT-07:00 Jelle Zijlstra : > I would be interested in doing this, although I haven't previously worked > on Cython itself. I'll start looking into it over the weekend. > > 2015-09-05 11:32 GMT-07:00 Stefan Behnel : > >> Hi! >> >> It looks like PEP 498 (f-strings) is going to be accepted soon. Anyone >> interested in implementing it for Cython? >> >> https://www.python.org/dev/peps/pep-0498/ >> >> It's certainly a bit of work, but it's also very much Python-level >> functionality and most of it can be handled in the parser, so I would >> count >> it as an entry-level project for working on Cython. There is already an >> initial implementation for CPython (in C) which should provide an answer >> to >> the tricky details of the functionality itself, as well as tests for it >> (eventually). >> >> https://bugs.python.org/issue24965 >> >> So, if this feature, and if extending the Cython language and working on a >> real compiler sounds tempting to you, please speak up on the cython-devel >> mailing list. >> >> Stefan >> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "cython-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to cython-users+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
[Cython] CPython incompatibility in string literal concatenation
While implementing PEP 498 I found a minor incompatibility between CPython and Cython: CPython lets you concatenate u-prefixed and non-prefixed string literals, while Cython throws an error. jelle@devjelle:~/cython$ cat concat.py print(u'foo' 'bar') jelle@devjelle:~/cython$ python concat.py foobar jelle@devjelle:~/cython$ cython concat.py Error compiling Cython file: ... print(u'foo' 'bar') ^ concat.py:1:13: Cannot mix string literals of different types, expected u'', got '' I tried both CPython 2.7 and 3.5. The documentation at https://docs.python.org/2/reference/lexical_analysis.html#string-literal-concatenation is ambiguous as to whether this behavior is intentional. As part of implementing PEP 498, I can make Cython's behavior match CPython's, unless there's a good reason to keep the incompatibility. ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Is it easy to do an "AST grep" of Cython code?
This seems doable in principle by using the Cython.Compiler.Visitor.TreeVisitor class. You'll have to figure out what Cython AST nodes the things you're looking for correspond to. As a simple example, this will find all non-def functions in a Cython file: from Cython.Compiler import TreeFragment, Visitor cython_code = unicode(open("filename.pyx").read()) class CdefFunFinder(Visitor.TreeVisitor): def visit_Node(self, node): self.visitchildren(node) def visit_CFuncDefNode(self, node): self.visitchildren(node) print self.dump_node(node) CdefFunFinder().visit(TreeFragment.parse_from_strings('', unicode(cython_code))) 2015-09-14 5:33 GMT-07:00 Nathaniel Smith : > I have a few hundred files worth of Cython code, and I'd like to find > all instances where a variable/expression has a certain cdef class > type. (More specifically, I'd like to find all accesses to the cdef > fields of a particular cdef class, but even just finding all 'cdef > MYTYPE x" and "x" statements would probably get me pretty > close.) Is there any easy way to do this? > > (The files are "every cython file on github or searchcode.com that > mentions the word "ufunc"", and I'm trying to find code that does > direct field access to the internals of the PyUFuncObject struct.) > > -- > Nathaniel J. Smith -- http://vorpus.org > ___ > cython-devel mailing list > cython-devel@python.org > https://mail.python.org/mailman/listinfo/cython-devel ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel