Skip to content

Commit 102f26d

Browse files
vstinnereendebakpt
andauthored
Apply suggestions from code review
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
1 parent 61e37e4 commit 102f26d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Objects/memoryobject.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3122,16 +3122,17 @@ memory_richcompare(PyObject *v, PyObject *w, int op)
31223122
}
31233123
vv = VIEW_ADDR(v);
31243124

3125-
// A memoryview is equal to itself: there is no need to compare individual
3126-
// values. This is not true for float values since they can be NaN, and NaN
3127-
// is not equal to itself. So only use this optimization on format known to
3125+
// For formats supported by the struct module a memoryview is equal to
3126+
// itself: there is no need to compare individual values.
3127+
// This is not true for float values since they can be NaN, and NaN
3128+
// is not equal to itself. So only use this optimization on format known to
31283129
// not use floats.
31293130
if (v == w) {
31303131
int can_compare_ptr;
31313132
const char *format = vv->format;
31323133
if (format != NULL) {
3133-
// Exclude formats "d" (double), "f" (float), "e" (16-bit float)
3134-
// and "P" (void*)
3134+
// Include only formats known by struct, exclude formats "d" (double),
3135+
// "f" (float), "e" (16-bit float) and "P" (void*)
31353136
can_compare_ptr = (strchr("bBchHiIlLnNqQ?", format[0]) != NULL
31363137
&& format[1] == 0);
31373138
}

0 commit comments

Comments
 (0)