Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Spurious warning "Unused entry 'genexpr'" #1699
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mhsmith commentedMay 6, 2017
•
edited
Cython version 0.25.2
l = [1,2,3] def f(): print(x for x in l)$ cython -Wextra -Werror foo.pyx Error compiling Cython file: ------------------------------------------------------------ ... l = [1,2,3] def f(): print(x for x in l) ^ ------------------------------------------------------------ foo.pyx:4:12: Unused entry 'genexpr'This only happens when the generator expression is in a function, rather than at the module level. Surrounding the expression with parentheses doesn't help. Converting it to a list comprehension does remove the warning, but will make performance worse, especially if the generator expression would not have run to completion.
I like to use
-Wextra -Werrorbecause the "unused" warnings often indicate a genuine error in my code.