Skip to content

Commit

Permalink
[gyb] Work-around PEP 3106 for Python 3 compatibility
Browse files Browse the repository at this point in the history
PEP 3106 [1] changed the behavior of the dictionaries `items` method.
In Python 2, `items` builds a real list of tuples where `iteritems`
returns a generator. PEP 3106 changes Python 3's `items` method to be
equivalent to Python 2's `iteritems` and completely removes `iteritems`
in Python 3.

This patch switches to both to use `items`. This could have a negative
impact on Python 2's performance because it now causes the dictionary
tuples to be built in memory.

[1] https://www.python.org/dev/peps/pep-3106/
  • Loading branch information
RLovelett committed Dec 31, 2015
1 parent 7dbb412 commit c8e74d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/GYBUnicodeDataUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, grapheme_break_property_file_name):
# values to symbolic values.
self.symbolic_values = \
[ None ] * (max(self.numeric_value_table.values()) + 1)
for k,v in self.numeric_value_table.iteritems():
for k,v in self.numeric_value_table.items():
self.symbolic_values[v] = k

# Load the data file.
Expand Down

0 comments on commit c8e74d1

Please sign in to comment.