Skip to content

Conversation

benjaminp
Copy link
Contributor

Remove redundant PyUnicode_Check call. Use a static table for checking chars.

Remove redundant PyUnicode_Check call. Use a static table for checking chars.
Copy link
Member

@tiran tiran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benjaminp benjaminp merged commit 9020ac7 into master Sep 8, 2017
@benjaminp benjaminp deleted the benjamin-all_name_chars branch September 8, 2017 01:09
@benjaminp
Copy link
Contributor Author

For posterity, here's how I generated the table:

for i in range(128):
    if chr(i) in "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz":
        print "1,",
    else:
        print "0,",
    if i % 16 == 15:
        print

@tiran
Copy link
Member

tiran commented Sep 8, 2017

I take back my LGTM ... you seriously used Python 2 to generate the table? Shame on you! :)

@tiran
Copy link
Member

tiran commented Sep 8, 2017

for i in range(128):
    print('{:d}, '.format(chr(i) in "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"), end='')
    if i % 16 == 15:
        print()

@benjaminp
Copy link
Contributor Author

It's just nostalgia.

@serhiy-storchaka
Copy link
Member

LGTM too. I have found a bug in all_name_chars(), but this is different issue.

@serhiy-storchaka
Copy link
Member

Only one nit: please update the comment before all_name_chars().

@serhiy-storchaka
Copy link
Member

You could use !Py_ISALNUM(*s) && *s != '_' and get rid of ok_name_char.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants