-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
Also make it an inclusive not exclusive filter, as the spec demands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've mentioned performance a couple of times, I wonder if its worth doing a quick benchmark to see how long it takes to serialise events?
for sub_field in field: | ||
if sub_field not in sub_out_dict: | ||
sub_out_dict[sub_field] = {} | ||
sub_out_dict = sub_out_dict[sub_field] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace the 3 lines with:
sub_out_dict = sub_out_dict.setdefault(sub_field, {})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
# for each element of the output array of arrays: | ||
# remove escaping so we can use the right key names. This purposefully avoids | ||
# using list comprehensions to avoid needless allocations as this may be called | ||
# on a lot of events. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick benchmark and the following list comprehension is actually quicker:
split_fields[:] = [ [field.replace(r'\.', r'.') for field in field_array] for field_array in split_fields]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if we really cared about performance, we would pull this up to be calculated when we initially parsed the filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
d = event_format(d) | ||
|
||
if (only_event_fields and isinstance(only_event_fields, list) and | ||
all(isinstance(f, basestring) for f in only_event_fields)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the args are incorrect this should raise an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
LGTM |
http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-user-userid-filter