Github user zero323 commented on a diff in the pull request:
https://github.com/apache/spark/pull/9098#discussion_r42055507
--- Diff: python/pyspark/mllib/linalg/__init__.py ---
@@ -769,10 +769,10 @@ def __getitem__(self, index):
if index >= self.size or index < 0:
raise ValueError("Index %d out of bounds." % index)
- insert_index = np.searchsorted(inds, index)
- if insert_index >= inds.size:
+ if (inds.size == 0) or (index > inds.item(-1)):
--- End diff --
By itself it is slower than using `__getitem__` but it returns standard
Python scalar and overall it should be marginally faster when index is a
standard scalar as well.
If you think that `inds[-1]` is better it shouldn't really matter. With
crude tests I get ~40 ns difference on average (245 ns for `[]` and, 205 ns for
`inds`)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]