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
case TARGET(BINARY_ADD): { | |
PyObject *right = POP(); | |
PyObject *left = TOP(); | |
PyObject *result; | |
if (PyUnicode_CheckExact(left) && | |
PyUnicode_CheckExact(right)) { | |
result = unicode_concatenate(tstate, left, right, f, next_instr); | |
} | |
else { | |
// Do this operation only when both the operands are numbers and |
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
#include <stdio.h> | |
#include <math.h> | |
int main(void) { | |
printf("%Lf\n", powl(2, 20000)); | |
return 0; | |
} | |
$ ./a.out | |
inf |
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
>>> 2 ** 20000 | |
39802768403379665923543072061912024537047727804924259387134 ... | |
... | |
... 6021 digits long ... | |
... | |
6309376 |
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
struct _longobject { | |
PyObject_VAR_HEAD | |
digit ob_digit[1]; | |
}; |
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
typedef struct { | |
PyObject ob_base; | |
Py_ssize_t ob_size; /* Number of items in variable part */ | |
} PyVarObject; |
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
struct _longobject { | |
PyObject ob_base; | |
Py_ssize_t ob_size; /* Number of items in variable part */ | |
digit ob_digit[1]; | |
}; |
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
... | |
for (i = 0; i < size_b; ++i) { | |
carry += a->ob_digit[i] + b->ob_digit[i]; | |
z->ob_digit[i] = carry & PyLong_MASK; | |
carry >>= PyLong_SHIFT; | |
} | |
for (; i < size_a; ++i) { | |
carry += a->ob_digit[i]; | |
z->ob_digit[i] = carry & PyLong_MASK; | |
carry >>= PyLong_SHIFT; |
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
... | |
for (i = 0; i < size_b; ++i) { | |
borrow = a->ob_digit[i] - b->ob_digit[i] - borrow; | |
z->ob_digit[i] = borrow & PyLong_MASK; | |
borrow >>= PyLong_SHIFT; | |
borrow &= 1; /* Keep only one sign bit */ | |
} | |
for (; i < size_a; ++i) { | |
borrow = a->ob_digit[i] - borrow; | |
z->ob_digit[i] = borrow & PyLong_MASK; |
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
def construct_tree(X, current_height, max_height): | |
"""The function constructs a tree/sub-tree on points X. | |
current_height: represents the height of the current tree to | |
the root of the decision tree. | |
max_height: the max height of the tree that should be constructed. | |
The current_height and max_height only exists to make the algorithm efficient | |
as we assume that no anomalies exist at depth >= max_height. | |
""" | |
if current_height >= max_height: | |
# here we are sure that no anomalies exist hence we |
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
def construct_forest(X, trees_count, subsample_count): | |
"""The function constructs a forest from given inputs/data points X. | |
""" | |
forest = [] | |
for i in range(0, trees_count): | |
# max_height is in fact the average height of the tree that would be | |
# constructed from given points. This acts as max_height for the | |
# construction because we are only interested in data points that have | |
# shorter-than-average path lengths, as those points are more likely | |
# to be anomalies. |