Uh oh!
There was an error while loading. Please reload this page.
prepare_iter_for_array PR - #43
Closed
chaburkland wants to merge 23 commits into
Closed
Conversation
chaburkland
marked this pull request as ready for review
April 28, 2021 22:29
chaburkland
commented
Apr 28, 2021
CollaboratorAuthor
Current performance |
flexatone
commented
May 15, 2021
Contributor
I have optimized the Python implementation of this function, which reduces and clarifies the requirements of this function. The new implementation is as follows: defprepare_iter_for_array(
values: tp.Iterable[tp.Any],
restrict_copy: bool=False
) ->tp.Tuple[DtypeSpecifier, bool, tp.Sequence[tp.Any]]:
is_gen, copy_values=is_gen_copy_values(values)
ifnotis_genandlen(values) ==0: #type: ignorereturnNone, False, values#type: ignoreifrestrict_copy:
copy_values=Falsev_iter=valuesifis_genelseiter(values)
ifcopy_values:
values_post= []
resolved=None# None is valid specifier if the type is not ambiguoushas_tuple=Falsehas_str=Falsehas_non_str=Falsehas_inexact=Falsehas_big_int=Falseforvinv_iter:
ifcopy_values:
# if a generator, have to make a copy while iteratingvalues_post.append(v)
value_type=type(v)
if (value_typeisstrorvalue_typeisnp.str_orvalue_typeisbytesorvalue_typeisnp.bytes_):
# must compare to both string typeshas_str=Trueelifhasattr(v, '__len__'):
# identify SF types by if they have STATIC attr they also must be assigned after array creation, so we treat them like tupleshas_tuple=Trueresolved=objectbreakelifisinstance(v, Enum):
# must check isinstance, as Enum types are always derived from Enumresolved=objectbreakelse:
has_non_str=Trueifvalue_typeinINEXACT_TYPES:
has_inexact=Trueelifvalue_typeisintandabs(v) >INT_MAX_COERCIBLE_TO_FLOAT:
has_big_int=Trueif (has_strandhas_non_str) or (has_big_intandhas_inexact):
resolved=objectbreakifcopy_values:
# v_iter is an iter, we need to finish itvalues_post.extend(v_iter)
returnresolved, has_tuple, values_postreturnresolved, has_tuple, values#type: ignore |
brandtbucher
removed their request for review
November 17, 2022 21:30
flexatone
commented
Aug 6, 2026
Contributor
A new PR has a fresh implementation of this with shared resources for 1D elementwise function application. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes#9