Skip to content

IGNITE-14058: Bool arrays now return as bool array, not int array#4

Closed
isapego wants to merge 3 commits intoapache:masterfrom
isapego:ignite-14058
Closed

IGNITE-14058: Bool arrays now return as bool array, not int array#4
isapego wants to merge 3 commits intoapache:masterfrom
isapego:ignite-14058

Conversation

@isapego
Copy link
Copy Markdown
Contributor

@isapego isapego commented Jan 25, 2021

No description provided.

Comment thread pyignite/datatypes/primitive_arrays.py Outdated

@classmethod
def to_python(cls, ctype_object, *args, **kwargs):
result = []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not ctype_object:
     return None
result = False * ctype_object.length
for i in range(ctype_objet.length):
     result[i] = ctype_object.data[i] != 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> def append_creation(n):
...     res = []
...     for _ in range(n):
...         res.append(False)
...     return res
... 
>>> timeit("False * 100", number=10000)
0.0005339730014384259
>>> timeit(lambda: append_creation(100), number=10000)
0.07856238499880419
>>> 

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that's how you do .reserve() in python :)

Copy link
Copy Markdown
Contributor

@ivandasch ivandasch Jan 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for mistake :(

if not ctype_object:
     return None
result = [False] * ctype_object.length
for i in range(ctype_objet.length):
     result[i] = ctype_object.data[i] != 0
>>> timeit("[False] * 100", number=10000)
0.014093294998019701
>>> timeit(lambda: append_creation(100), number=10000)
0.07997436200093944
>>>

@asfgit asfgit closed this in 4ca871d Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants