codon/stdlib/collections.codon

439 lines
12 KiB
Python
Raw Normal View History

2022-01-24 12:15:06 +08:00
# (c) 2022 Exaloop Inc. All rights reserved.
2022-02-16 23:51:16 +08:00
from internal.types.optional import unwrap
2022-01-24 12:15:06 +08:00
class deque:
2021-09-28 02:02:44 +08:00
_arr: Array[T]
_head: int
_tail: int
_maxlen: int
2022-02-16 23:51:16 +08:00
T: type
2021-09-28 02:02:44 +08:00
2022-02-16 23:51:16 +08:00
def __init__(self, arr: Array[T], head: int, tail: int, maxlen: int):
2021-09-28 02:02:44 +08:00
self._arr = arr
self._head = head
self._tail = tail
self._maxlen = maxlen
2022-02-16 23:51:16 +08:00
def __init__(self):
2021-09-28 02:02:44 +08:00
self._arr = Array[T](16)
self._head = 0
self._tail = 0
self._maxlen = -1
2022-02-16 23:51:16 +08:00
def __init__(self, maxlen: int):
2021-09-28 02:02:44 +08:00
cap = 1
while cap < maxlen:
cap *= 2
self._arr = Array[T](cap)
self._head = 0
self._tail = 0
self._maxlen = maxlen
2022-02-16 23:51:16 +08:00
def __init__(self, it: Generator[T]):
2021-09-28 02:02:44 +08:00
self._arr = Array[T](16)
self._head = 0
self._tail = 0
self._maxlen = -1
for i in it:
self.append(i)
@property
2022-01-24 12:15:06 +08:00
def maxlen(self) -> int:
2021-09-28 02:02:44 +08:00
return self._maxlen
2022-02-16 23:51:16 +08:00
def _double_cap(self):
2021-09-28 02:02:44 +08:00
p = self._head
n = len(self._arr)
r = n - p
new_cap = n * 2
new_arr = Array[T](new_cap)
for i in range(r):
new_arr[i] = self._arr[p + i]
for i in range(p):
new_arr[i + r] = self._arr[i]
self._arr = new_arr
self._head = 0
self._tail = n
2022-02-16 23:51:16 +08:00
def _check_not_empty(self):
2021-09-28 02:02:44 +08:00
if not self:
raise IndexError("pop from an empty deque")
2022-01-24 12:15:06 +08:00
def __bool__(self) -> bool:
2021-09-28 02:02:44 +08:00
return self._head != self._tail
2022-01-24 12:15:06 +08:00
def __len__(self) -> int:
2021-09-28 02:02:44 +08:00
return (self._tail - self._head) & (len(self._arr) - 1)
2022-02-16 23:51:16 +08:00
def appendleft(self, x: T):
2021-09-28 02:02:44 +08:00
self._head = (self._head - 1) & (len(self._arr) - 1)
self._arr[self._head] = x
if self._maxlen >= 0 and len(self) > self._maxlen:
self.pop()
if self._head == self._tail:
self._double_cap()
2022-02-16 23:51:16 +08:00
def append(self, x: T):
2021-09-28 02:02:44 +08:00
self._arr[self._tail] = x
self._tail = (self._tail + 1) & (len(self._arr) - 1)
if self._maxlen >= 0 and len(self) > self._maxlen:
self.popleft()
if self._head == self._tail:
self._double_cap()
2022-01-24 12:15:06 +08:00
def popleft(self) -> T:
2021-09-28 02:02:44 +08:00
self._check_not_empty()
res = self._arr[self._head]
self._head = (self._head + 1) & (len(self._arr) - 1)
return res
2022-01-24 12:15:06 +08:00
def pop(self) -> T:
2021-09-28 02:02:44 +08:00
self._check_not_empty()
self._tail = (self._tail - 1) & (len(self._arr) - 1)
return self._arr[self._tail]
2022-02-16 23:51:16 +08:00
def clear(self):
2021-09-28 02:02:44 +08:00
self._head = 0
self._tail = 0
2022-01-24 12:15:06 +08:00
def __iter__(self) -> Generator[T]:
2021-09-28 02:02:44 +08:00
i = self._head
while i != self._tail:
yield self._arr[i]
i = (i + 1) & (len(self._arr) - 1)
2022-01-24 12:15:06 +08:00
def __contains__(self, x: T) -> bool:
2021-09-28 02:02:44 +08:00
for i in self:
if i == x:
return True
return False
2022-01-24 12:15:06 +08:00
def __deepcopy__(self) -> deque[T]:
2021-12-11 04:28:19 +08:00
return deque(i.__deepcopy__() for i in self)
2022-01-24 12:15:06 +08:00
def __copy__(self) -> deque[T]:
GPU and other updates (#52) * Add nvptx pass * Fix spaces * Don't change name * Add runtime support * Add init call * Add more runtime functions * Add launch function * Add intrinsics * Fix codegen * Run GPU pass between general opt passes * Set data layout * Create context * Link libdevice * Add function remapping * Fix linkage * Fix libdevice link * Fix linking * Fix personality * Fix linking * Fix linking * Fix linking * Add internalize pass * Add more math conversions * Add more re-mappings * Fix conversions * Fix __str__ * Add decorator attribute for any decorator * Update kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Remove old decorator * Fix pointer calc * Fix fill-in codegen * Fix linkage * Add comment * Update list conversion * Add more conversions * Add dict and set conversions * Add float32 type to IR/LLVM * Add float32 * Add float32 stdlib * Keep required global values in PTX module * Fix PTX module pruning * Fix malloc * Set will-return * Fix name cleanup * Fix access * Fix name cleanup * Fix function renaming * Update dimension API * Fix args * Clean up API * Move GPU transformations to end of opt pipeline * Fix alloc replacements * Fix naming * Target PTX 4.2 * Fix global renaming * Fix early return in static blocks; Add __realized__ function * Format * Add __llvm_name__ for functions * Add vector type to IR * SIMD support [wip] * Update kernel naming * Fix early returns; Fix SIMD calls * Fix kernel naming * Fix IR matcher * Remove module print * Update realloc * Add overloads for 32-bit float math ops * Add gpu.Pointer type for working with raw pointers * Add float32 conversion * Add to_gpu and from_gpu * clang-format * Add f32 reduction support to OpenMP * Fix automatic GPU class conversions * Fix conversion functions * Fix conversions * Rename self * Fix tuple conversion * Fix conversions * Fix conversions * Update PTX filename * Fix filename * Add raw function * Add GPU docs * Allow nested object conversions * Add tests (WIP) * Update SIMD * Add staticrange and statictuple loop support * SIMD updates * Add new Vec constructors * Fix UInt conversion * Fix size-0 allocs * Add more tests * Add matmul test * Rename gpu test file * Add more tests * Add alloc cache * Fix object_to_gpu * Fix frees * Fix str conversion * Fix set conversion * Fix conversions * Fix class conversion * Fix str conversion * Fix byte conversion * Fix list conversion * Fix pointer conversions * Fix conversions * Fix conversions * Update tests * Fix conversions * Fix tuple conversion * Fix tuple conversion * Fix auto conversions * Fix conversion * Fix magics * Update tests * Support GPU in JIT mode * Fix GPU+JIT * Fix kernel filename in JIT mode * Add __static_print__; Add earlyDefines; Various domination bugfixes; SimplifyContext RAII base handling * Fix global static handling * Fix float32 tests * FIx gpu module * Support OpenMP "collapse" option * Add more collapse tests * Capture generics and statics * TraitVar handling * Python exceptions / isinstance [wip; no_ci] * clang-format * Add list comparison operators * Support empty raise in IR * Add dict 'or' operator * Fix repr * Add copy module * Fix spacing * Use sm_30 * Python exceptions * TypeTrait support; Fix defaultDict * Fix earlyDefines * Add defaultdict * clang-format * Fix invalid canonicalizations * Fix empty raise * Fix copyright * Add Python numerics option * Support py-numerics in math module * Update docs * Add static Python division / modulus * Add static py numerics tests * Fix staticrange/tuple; Add KwTuple.__getitem__ * clang-format * Add gpu parameter to par * Fix globals * Don't init loop vars on loop collapse * Add par-gpu tests * Update gpu docs * Fix isinstance check * Remove invalid test * Add -libdevice to set custom path [skip ci] * Add release notes; bump version [skip ci] * Add libdevice docs [skip ci] Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>
2022-09-16 03:40:00 +08:00
return deque[T](self._arr.__copy__(), self._head, self._tail, self._maxlen)
2021-09-28 02:02:44 +08:00
2022-01-24 12:15:06 +08:00
def copy(self) -> deque[T]:
2021-09-28 02:02:44 +08:00
return self.__copy__()
2022-01-24 12:15:06 +08:00
def __repr__(self) -> str:
GPU and other updates (#52) * Add nvptx pass * Fix spaces * Don't change name * Add runtime support * Add init call * Add more runtime functions * Add launch function * Add intrinsics * Fix codegen * Run GPU pass between general opt passes * Set data layout * Create context * Link libdevice * Add function remapping * Fix linkage * Fix libdevice link * Fix linking * Fix personality * Fix linking * Fix linking * Fix linking * Add internalize pass * Add more math conversions * Add more re-mappings * Fix conversions * Fix __str__ * Add decorator attribute for any decorator * Update kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Remove old decorator * Fix pointer calc * Fix fill-in codegen * Fix linkage * Add comment * Update list conversion * Add more conversions * Add dict and set conversions * Add float32 type to IR/LLVM * Add float32 * Add float32 stdlib * Keep required global values in PTX module * Fix PTX module pruning * Fix malloc * Set will-return * Fix name cleanup * Fix access * Fix name cleanup * Fix function renaming * Update dimension API * Fix args * Clean up API * Move GPU transformations to end of opt pipeline * Fix alloc replacements * Fix naming * Target PTX 4.2 * Fix global renaming * Fix early return in static blocks; Add __realized__ function * Format * Add __llvm_name__ for functions * Add vector type to IR * SIMD support [wip] * Update kernel naming * Fix early returns; Fix SIMD calls * Fix kernel naming * Fix IR matcher * Remove module print * Update realloc * Add overloads for 32-bit float math ops * Add gpu.Pointer type for working with raw pointers * Add float32 conversion * Add to_gpu and from_gpu * clang-format * Add f32 reduction support to OpenMP * Fix automatic GPU class conversions * Fix conversion functions * Fix conversions * Rename self * Fix tuple conversion * Fix conversions * Fix conversions * Update PTX filename * Fix filename * Add raw function * Add GPU docs * Allow nested object conversions * Add tests (WIP) * Update SIMD * Add staticrange and statictuple loop support * SIMD updates * Add new Vec constructors * Fix UInt conversion * Fix size-0 allocs * Add more tests * Add matmul test * Rename gpu test file * Add more tests * Add alloc cache * Fix object_to_gpu * Fix frees * Fix str conversion * Fix set conversion * Fix conversions * Fix class conversion * Fix str conversion * Fix byte conversion * Fix list conversion * Fix pointer conversions * Fix conversions * Fix conversions * Update tests * Fix conversions * Fix tuple conversion * Fix tuple conversion * Fix auto conversions * Fix conversion * Fix magics * Update tests * Support GPU in JIT mode * Fix GPU+JIT * Fix kernel filename in JIT mode * Add __static_print__; Add earlyDefines; Various domination bugfixes; SimplifyContext RAII base handling * Fix global static handling * Fix float32 tests * FIx gpu module * Support OpenMP "collapse" option * Add more collapse tests * Capture generics and statics * TraitVar handling * Python exceptions / isinstance [wip; no_ci] * clang-format * Add list comparison operators * Support empty raise in IR * Add dict 'or' operator * Fix repr * Add copy module * Fix spacing * Use sm_30 * Python exceptions * TypeTrait support; Fix defaultDict * Fix earlyDefines * Add defaultdict * clang-format * Fix invalid canonicalizations * Fix empty raise * Fix copyright * Add Python numerics option * Support py-numerics in math module * Update docs * Add static Python division / modulus * Add static py numerics tests * Fix staticrange/tuple; Add KwTuple.__getitem__ * clang-format * Add gpu parameter to par * Fix globals * Don't init loop vars on loop collapse * Add par-gpu tests * Update gpu docs * Fix isinstance check * Remove invalid test * Add -libdevice to set custom path [skip ci] * Add release notes; bump version [skip ci] * Add libdevice docs [skip ci] Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>
2022-09-16 03:40:00 +08:00
return f"deque({repr(List[T](iter(self)))})"
2021-09-28 02:02:44 +08:00
2022-02-16 23:51:16 +08:00
def _idx_check(self, idx: int, msg: str):
2021-09-28 02:02:44 +08:00
if self._head == self._tail or idx >= len(self) or idx < 0:
raise IndexError(msg)
@property
2022-01-24 12:15:06 +08:00
def left(self) -> T:
2021-09-28 02:02:44 +08:00
self._idx_check(0, "list index out of range")
return self._arr[self._head]
2022-01-24 12:15:06 +08:00
def __getitem__(self, idx: int) -> T:
2021-09-28 02:02:44 +08:00
if idx < 0:
idx += len(self)
self._idx_check(idx, "list index out of range")
if self._head <= self._tail:
return self._arr[self._head + idx]
elif self._head + idx < len(self._arr):
return self._arr[self._head + idx]
else:
idx -= len(self._arr) - self._head
assert 0 <= idx < self._tail
return self._arr[idx]
2022-01-24 12:15:06 +08:00
2021-09-28 02:02:44 +08:00
@tuple
2022-01-24 12:15:06 +08:00
class _CounterItem:
2021-09-28 02:02:44 +08:00
element: T
count: int
2022-02-16 23:51:16 +08:00
T: type
2021-09-28 02:02:44 +08:00
2022-01-24 12:15:06 +08:00
def __eq__(self, other: _CounterItem[T]) -> bool:
2021-09-28 02:02:44 +08:00
return self.count == other.count
2022-01-24 12:15:06 +08:00
def __ne__(self, other: _CounterItem[T]) -> bool:
2021-09-28 02:02:44 +08:00
return self.count != other.count
2022-01-24 12:15:06 +08:00
def __lt__(self, other: _CounterItem[T]) -> bool:
2021-09-28 02:02:44 +08:00
return self.count < other.count
2022-01-24 12:15:06 +08:00
def __gt__(self, other: _CounterItem[T]) -> bool:
2021-09-28 02:02:44 +08:00
return self.count > other.count
2022-01-24 12:15:06 +08:00
def __le__(self, other: _CounterItem[T]) -> bool:
2021-09-28 02:02:44 +08:00
return self.count <= other.count
2022-01-24 12:15:06 +08:00
def __ge__(self, other: _CounterItem[T]) -> bool:
2021-09-28 02:02:44 +08:00
return self.count >= other.count
2022-01-24 12:15:06 +08:00
class Counter(Dict[T, int]):
T: type
2022-02-16 23:51:16 +08:00
def __init__(self, elements: Generator[T]):
2021-09-28 02:02:44 +08:00
self._init()
self.update(elements)
2022-02-16 23:51:16 +08:00
def __init__(self, other: Counter[T]):
2021-09-28 02:02:44 +08:00
self._init_from(other)
2022-02-16 23:51:16 +08:00
def __init__(self, other: Dict[T, int]):
2021-09-28 02:02:44 +08:00
self._init_from(other)
2022-01-24 12:15:06 +08:00
def elements(self) -> Generator[T]:
for k, v in self.items():
2021-09-28 02:02:44 +08:00
for i in range(v):
yield k
2022-01-24 12:15:06 +08:00
def most_common(self, n: Optional[int] = None) -> List[Tuple[T, int]]:
2021-09-28 02:02:44 +08:00
if len(self) == 0:
return List[_CounterItem](capacity=0)
if n is None:
v = List[_CounterItem](capacity=len(self))
for t in self.items():
v.append(t)
v.sort(reverse=True)
return v
else:
from heapq import heapify, heapreplace
2022-02-16 23:51:16 +08:00
n: int = n
2022-01-24 12:15:06 +08:00
if n == 1:
2021-09-28 02:02:44 +08:00
top: Optional[_CounterItem] = None
for t in self.items():
if top is None or t[1] > top.count:
top = t
2022-02-16 23:51:16 +08:00
return [unwrap(top)]
2021-09-28 02:02:44 +08:00
2022-01-24 12:15:06 +08:00
if n <= 0:
2021-09-28 02:02:44 +08:00
return List[_CounterItem](capacity=0)
2022-01-24 12:15:06 +08:00
result = List[_CounterItem](capacity=n)
2021-09-28 02:02:44 +08:00
for t in self.items():
2022-01-24 12:15:06 +08:00
if len(result) < n:
2021-09-28 02:02:44 +08:00
result.append(t)
2022-01-24 12:15:06 +08:00
if len(result) == n:
2021-09-28 02:02:44 +08:00
heapify(result)
else:
if result[0] < t:
heapreplace(result, t)
result.sort(reverse=True)
return result
2022-02-16 23:51:16 +08:00
def subtract(self, elements: Generator[T]):
2021-09-28 02:02:44 +08:00
for a in elements:
self.increment(a, -1)
2022-02-16 23:51:16 +08:00
def subtract(self, other: Counter[T]):
2022-01-24 12:15:06 +08:00
for k, v in other.items():
2021-09-28 02:02:44 +08:00
self.increment(k, -v)
2022-02-16 23:51:16 +08:00
def subtract(self, other: Dict[T, int]):
2022-01-24 12:15:06 +08:00
for k, v in other.items():
2021-09-28 02:02:44 +08:00
self.increment(k, -v)
2022-02-16 23:51:16 +08:00
def update(self, elements: Generator[T]):
2021-09-28 02:02:44 +08:00
for a in elements:
2022-02-16 23:51:16 +08:00
self.increment(a)
2021-09-28 02:02:44 +08:00
2022-02-16 23:51:16 +08:00
def update(self, other: Counter[T]):
2022-01-24 12:15:06 +08:00
for k, v in other.items():
2021-09-28 02:02:44 +08:00
self.increment(k, by=v)
2022-02-16 23:51:16 +08:00
def update(self, other: Dict[T, int]):
2022-01-24 12:15:06 +08:00
for k, v in other.items():
2021-09-28 02:02:44 +08:00
self.increment(k, by=v)
2022-02-16 23:51:16 +08:00
def update(self):
2021-09-28 02:02:44 +08:00
pass
2022-01-24 12:15:06 +08:00
def total(self) -> int:
2021-09-28 02:02:44 +08:00
m = 0
for v in self.values():
m += v
return m
2022-01-24 12:15:06 +08:00
def __getitem__(self, key: T) -> int:
2021-09-28 02:02:44 +08:00
return self.get(key, 0)
2022-02-16 23:51:16 +08:00
def __delitem__(self, key: T):
2021-09-28 02:02:44 +08:00
x = self._kh_get(key)
if x != self._kh_end():
self._kh_del(x)
2022-01-24 12:15:06 +08:00
def __eq__(self, other: Counter[T]) -> bool:
2021-09-28 02:02:44 +08:00
if self.__len__() != other.__len__():
return False
2022-01-24 12:15:06 +08:00
for k, v in self.items():
2021-09-28 02:02:44 +08:00
if k not in other or other[k] != v:
return False
return True
2022-01-24 12:15:06 +08:00
def __ne__(self, other: Counter[T]) -> bool:
2021-09-28 02:02:44 +08:00
return not (self == other)
2022-01-24 12:15:06 +08:00
def __copy__(self) -> Counter[T]:
2021-09-28 02:02:44 +08:00
return Counter[T](self)
2022-01-24 12:15:06 +08:00
def __iadd__(self, other: Counter[T]) -> Counter[T]:
for k, v in other.items():
2021-09-28 02:02:44 +08:00
self.increment(k, by=v)
self._del_non_positives()
return self
2022-01-24 12:15:06 +08:00
def __isub__(self, other: Counter[T]) -> Counter[T]:
for k, v in other.items():
2021-09-28 02:02:44 +08:00
self.increment(k, by=-v)
self._del_non_positives()
return self
2022-01-24 12:15:06 +08:00
def __iand__(self, other: Counter[T]) -> Counter[T]:
for k, v in other.items():
2021-09-28 02:02:44 +08:00
self[k] = min(self.get(k, 0), v)
self._del_non_positives()
return self
2022-01-24 12:15:06 +08:00
def __ior__(self, other: Counter[T]) -> Counter[T]:
2021-09-28 02:02:44 +08:00
self._del_non_positives()
2022-01-24 12:15:06 +08:00
for k, v in other.items():
2021-09-28 02:02:44 +08:00
self[k] = max(self.get(k, 0), v)
self._del_non_positives()
return self
2022-01-24 12:15:06 +08:00
def __pos__(self) -> Counter[T]:
2021-09-28 02:02:44 +08:00
result = Counter[T]()
result.resize(self._n_buckets)
2022-01-24 12:15:06 +08:00
for k, v in self.items():
2021-09-28 02:02:44 +08:00
if v > 0:
result[k] = v
return result
2022-01-24 12:15:06 +08:00
def __neg__(self) -> Counter[T]:
2021-09-28 02:02:44 +08:00
result = Counter[T]()
result.resize(self._n_buckets)
2022-01-24 12:15:06 +08:00
for k, v in self.items():
2021-09-28 02:02:44 +08:00
if v < 0:
result[k] = -v
return result
2022-01-24 12:15:06 +08:00
def __add__(self, other: Counter[T]) -> Counter[T]:
GPU and other updates (#52) * Add nvptx pass * Fix spaces * Don't change name * Add runtime support * Add init call * Add more runtime functions * Add launch function * Add intrinsics * Fix codegen * Run GPU pass between general opt passes * Set data layout * Create context * Link libdevice * Add function remapping * Fix linkage * Fix libdevice link * Fix linking * Fix personality * Fix linking * Fix linking * Fix linking * Add internalize pass * Add more math conversions * Add more re-mappings * Fix conversions * Fix __str__ * Add decorator attribute for any decorator * Update kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Remove old decorator * Fix pointer calc * Fix fill-in codegen * Fix linkage * Add comment * Update list conversion * Add more conversions * Add dict and set conversions * Add float32 type to IR/LLVM * Add float32 * Add float32 stdlib * Keep required global values in PTX module * Fix PTX module pruning * Fix malloc * Set will-return * Fix name cleanup * Fix access * Fix name cleanup * Fix function renaming * Update dimension API * Fix args * Clean up API * Move GPU transformations to end of opt pipeline * Fix alloc replacements * Fix naming * Target PTX 4.2 * Fix global renaming * Fix early return in static blocks; Add __realized__ function * Format * Add __llvm_name__ for functions * Add vector type to IR * SIMD support [wip] * Update kernel naming * Fix early returns; Fix SIMD calls * Fix kernel naming * Fix IR matcher * Remove module print * Update realloc * Add overloads for 32-bit float math ops * Add gpu.Pointer type for working with raw pointers * Add float32 conversion * Add to_gpu and from_gpu * clang-format * Add f32 reduction support to OpenMP * Fix automatic GPU class conversions * Fix conversion functions * Fix conversions * Rename self * Fix tuple conversion * Fix conversions * Fix conversions * Update PTX filename * Fix filename * Add raw function * Add GPU docs * Allow nested object conversions * Add tests (WIP) * Update SIMD * Add staticrange and statictuple loop support * SIMD updates * Add new Vec constructors * Fix UInt conversion * Fix size-0 allocs * Add more tests * Add matmul test * Rename gpu test file * Add more tests * Add alloc cache * Fix object_to_gpu * Fix frees * Fix str conversion * Fix set conversion * Fix conversions * Fix class conversion * Fix str conversion * Fix byte conversion * Fix list conversion * Fix pointer conversions * Fix conversions * Fix conversions * Update tests * Fix conversions * Fix tuple conversion * Fix tuple conversion * Fix auto conversions * Fix conversion * Fix magics * Update tests * Support GPU in JIT mode * Fix GPU+JIT * Fix kernel filename in JIT mode * Add __static_print__; Add earlyDefines; Various domination bugfixes; SimplifyContext RAII base handling * Fix global static handling * Fix float32 tests * FIx gpu module * Support OpenMP "collapse" option * Add more collapse tests * Capture generics and statics * TraitVar handling * Python exceptions / isinstance [wip; no_ci] * clang-format * Add list comparison operators * Support empty raise in IR * Add dict 'or' operator * Fix repr * Add copy module * Fix spacing * Use sm_30 * Python exceptions * TypeTrait support; Fix defaultDict * Fix earlyDefines * Add defaultdict * clang-format * Fix invalid canonicalizations * Fix empty raise * Fix copyright * Add Python numerics option * Support py-numerics in math module * Update docs * Add static Python division / modulus * Add static py numerics tests * Fix staticrange/tuple; Add KwTuple.__getitem__ * clang-format * Add gpu parameter to par * Fix globals * Don't init loop vars on loop collapse * Add par-gpu tests * Update gpu docs * Fix isinstance check * Remove invalid test * Add -libdevice to set custom path [skip ci] * Add release notes; bump version [skip ci] * Add libdevice docs [skip ci] Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>
2022-09-16 03:40:00 +08:00
result = self.__copy__()
2021-09-28 02:02:44 +08:00
result += other
return result
2022-01-24 12:15:06 +08:00
def __sub__(self, other: Counter[T]) -> Counter[T]:
GPU and other updates (#52) * Add nvptx pass * Fix spaces * Don't change name * Add runtime support * Add init call * Add more runtime functions * Add launch function * Add intrinsics * Fix codegen * Run GPU pass between general opt passes * Set data layout * Create context * Link libdevice * Add function remapping * Fix linkage * Fix libdevice link * Fix linking * Fix personality * Fix linking * Fix linking * Fix linking * Add internalize pass * Add more math conversions * Add more re-mappings * Fix conversions * Fix __str__ * Add decorator attribute for any decorator * Update kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Remove old decorator * Fix pointer calc * Fix fill-in codegen * Fix linkage * Add comment * Update list conversion * Add more conversions * Add dict and set conversions * Add float32 type to IR/LLVM * Add float32 * Add float32 stdlib * Keep required global values in PTX module * Fix PTX module pruning * Fix malloc * Set will-return * Fix name cleanup * Fix access * Fix name cleanup * Fix function renaming * Update dimension API * Fix args * Clean up API * Move GPU transformations to end of opt pipeline * Fix alloc replacements * Fix naming * Target PTX 4.2 * Fix global renaming * Fix early return in static blocks; Add __realized__ function * Format * Add __llvm_name__ for functions * Add vector type to IR * SIMD support [wip] * Update kernel naming * Fix early returns; Fix SIMD calls * Fix kernel naming * Fix IR matcher * Remove module print * Update realloc * Add overloads for 32-bit float math ops * Add gpu.Pointer type for working with raw pointers * Add float32 conversion * Add to_gpu and from_gpu * clang-format * Add f32 reduction support to OpenMP * Fix automatic GPU class conversions * Fix conversion functions * Fix conversions * Rename self * Fix tuple conversion * Fix conversions * Fix conversions * Update PTX filename * Fix filename * Add raw function * Add GPU docs * Allow nested object conversions * Add tests (WIP) * Update SIMD * Add staticrange and statictuple loop support * SIMD updates * Add new Vec constructors * Fix UInt conversion * Fix size-0 allocs * Add more tests * Add matmul test * Rename gpu test file * Add more tests * Add alloc cache * Fix object_to_gpu * Fix frees * Fix str conversion * Fix set conversion * Fix conversions * Fix class conversion * Fix str conversion * Fix byte conversion * Fix list conversion * Fix pointer conversions * Fix conversions * Fix conversions * Update tests * Fix conversions * Fix tuple conversion * Fix tuple conversion * Fix auto conversions * Fix conversion * Fix magics * Update tests * Support GPU in JIT mode * Fix GPU+JIT * Fix kernel filename in JIT mode * Add __static_print__; Add earlyDefines; Various domination bugfixes; SimplifyContext RAII base handling * Fix global static handling * Fix float32 tests * FIx gpu module * Support OpenMP "collapse" option * Add more collapse tests * Capture generics and statics * TraitVar handling * Python exceptions / isinstance [wip; no_ci] * clang-format * Add list comparison operators * Support empty raise in IR * Add dict 'or' operator * Fix repr * Add copy module * Fix spacing * Use sm_30 * Python exceptions * TypeTrait support; Fix defaultDict * Fix earlyDefines * Add defaultdict * clang-format * Fix invalid canonicalizations * Fix empty raise * Fix copyright * Add Python numerics option * Support py-numerics in math module * Update docs * Add static Python division / modulus * Add static py numerics tests * Fix staticrange/tuple; Add KwTuple.__getitem__ * clang-format * Add gpu parameter to par * Fix globals * Don't init loop vars on loop collapse * Add par-gpu tests * Update gpu docs * Fix isinstance check * Remove invalid test * Add -libdevice to set custom path [skip ci] * Add release notes; bump version [skip ci] * Add libdevice docs [skip ci] Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>
2022-09-16 03:40:00 +08:00
result = self.__copy__()
2021-09-28 02:02:44 +08:00
result -= other
return result
2022-01-24 12:15:06 +08:00
def __and__(self, other: Counter[T]) -> Counter[T]:
GPU and other updates (#52) * Add nvptx pass * Fix spaces * Don't change name * Add runtime support * Add init call * Add more runtime functions * Add launch function * Add intrinsics * Fix codegen * Run GPU pass between general opt passes * Set data layout * Create context * Link libdevice * Add function remapping * Fix linkage * Fix libdevice link * Fix linking * Fix personality * Fix linking * Fix linking * Fix linking * Add internalize pass * Add more math conversions * Add more re-mappings * Fix conversions * Fix __str__ * Add decorator attribute for any decorator * Update kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Remove old decorator * Fix pointer calc * Fix fill-in codegen * Fix linkage * Add comment * Update list conversion * Add more conversions * Add dict and set conversions * Add float32 type to IR/LLVM * Add float32 * Add float32 stdlib * Keep required global values in PTX module * Fix PTX module pruning * Fix malloc * Set will-return * Fix name cleanup * Fix access * Fix name cleanup * Fix function renaming * Update dimension API * Fix args * Clean up API * Move GPU transformations to end of opt pipeline * Fix alloc replacements * Fix naming * Target PTX 4.2 * Fix global renaming * Fix early return in static blocks; Add __realized__ function * Format * Add __llvm_name__ for functions * Add vector type to IR * SIMD support [wip] * Update kernel naming * Fix early returns; Fix SIMD calls * Fix kernel naming * Fix IR matcher * Remove module print * Update realloc * Add overloads for 32-bit float math ops * Add gpu.Pointer type for working with raw pointers * Add float32 conversion * Add to_gpu and from_gpu * clang-format * Add f32 reduction support to OpenMP * Fix automatic GPU class conversions * Fix conversion functions * Fix conversions * Rename self * Fix tuple conversion * Fix conversions * Fix conversions * Update PTX filename * Fix filename * Add raw function * Add GPU docs * Allow nested object conversions * Add tests (WIP) * Update SIMD * Add staticrange and statictuple loop support * SIMD updates * Add new Vec constructors * Fix UInt conversion * Fix size-0 allocs * Add more tests * Add matmul test * Rename gpu test file * Add more tests * Add alloc cache * Fix object_to_gpu * Fix frees * Fix str conversion * Fix set conversion * Fix conversions * Fix class conversion * Fix str conversion * Fix byte conversion * Fix list conversion * Fix pointer conversions * Fix conversions * Fix conversions * Update tests * Fix conversions * Fix tuple conversion * Fix tuple conversion * Fix auto conversions * Fix conversion * Fix magics * Update tests * Support GPU in JIT mode * Fix GPU+JIT * Fix kernel filename in JIT mode * Add __static_print__; Add earlyDefines; Various domination bugfixes; SimplifyContext RAII base handling * Fix global static handling * Fix float32 tests * FIx gpu module * Support OpenMP "collapse" option * Add more collapse tests * Capture generics and statics * TraitVar handling * Python exceptions / isinstance [wip; no_ci] * clang-format * Add list comparison operators * Support empty raise in IR * Add dict 'or' operator * Fix repr * Add copy module * Fix spacing * Use sm_30 * Python exceptions * TypeTrait support; Fix defaultDict * Fix earlyDefines * Add defaultdict * clang-format * Fix invalid canonicalizations * Fix empty raise * Fix copyright * Add Python numerics option * Support py-numerics in math module * Update docs * Add static Python division / modulus * Add static py numerics tests * Fix staticrange/tuple; Add KwTuple.__getitem__ * clang-format * Add gpu parameter to par * Fix globals * Don't init loop vars on loop collapse * Add par-gpu tests * Update gpu docs * Fix isinstance check * Remove invalid test * Add -libdevice to set custom path [skip ci] * Add release notes; bump version [skip ci] * Add libdevice docs [skip ci] Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>
2022-09-16 03:40:00 +08:00
result = self.__copy__()
2021-09-28 02:02:44 +08:00
result &= other
return result
2022-01-24 12:15:06 +08:00
def __or__(self, other: Counter[T]) -> Counter[T]:
GPU and other updates (#52) * Add nvptx pass * Fix spaces * Don't change name * Add runtime support * Add init call * Add more runtime functions * Add launch function * Add intrinsics * Fix codegen * Run GPU pass between general opt passes * Set data layout * Create context * Link libdevice * Add function remapping * Fix linkage * Fix libdevice link * Fix linking * Fix personality * Fix linking * Fix linking * Fix linking * Add internalize pass * Add more math conversions * Add more re-mappings * Fix conversions * Fix __str__ * Add decorator attribute for any decorator * Update kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Remove old decorator * Fix pointer calc * Fix fill-in codegen * Fix linkage * Add comment * Update list conversion * Add more conversions * Add dict and set conversions * Add float32 type to IR/LLVM * Add float32 * Add float32 stdlib * Keep required global values in PTX module * Fix PTX module pruning * Fix malloc * Set will-return * Fix name cleanup * Fix access * Fix name cleanup * Fix function renaming * Update dimension API * Fix args * Clean up API * Move GPU transformations to end of opt pipeline * Fix alloc replacements * Fix naming * Target PTX 4.2 * Fix global renaming * Fix early return in static blocks; Add __realized__ function * Format * Add __llvm_name__ for functions * Add vector type to IR * SIMD support [wip] * Update kernel naming * Fix early returns; Fix SIMD calls * Fix kernel naming * Fix IR matcher * Remove module print * Update realloc * Add overloads for 32-bit float math ops * Add gpu.Pointer type for working with raw pointers * Add float32 conversion * Add to_gpu and from_gpu * clang-format * Add f32 reduction support to OpenMP * Fix automatic GPU class conversions * Fix conversion functions * Fix conversions * Rename self * Fix tuple conversion * Fix conversions * Fix conversions * Update PTX filename * Fix filename * Add raw function * Add GPU docs * Allow nested object conversions * Add tests (WIP) * Update SIMD * Add staticrange and statictuple loop support * SIMD updates * Add new Vec constructors * Fix UInt conversion * Fix size-0 allocs * Add more tests * Add matmul test * Rename gpu test file * Add more tests * Add alloc cache * Fix object_to_gpu * Fix frees * Fix str conversion * Fix set conversion * Fix conversions * Fix class conversion * Fix str conversion * Fix byte conversion * Fix list conversion * Fix pointer conversions * Fix conversions * Fix conversions * Update tests * Fix conversions * Fix tuple conversion * Fix tuple conversion * Fix auto conversions * Fix conversion * Fix magics * Update tests * Support GPU in JIT mode * Fix GPU+JIT * Fix kernel filename in JIT mode * Add __static_print__; Add earlyDefines; Various domination bugfixes; SimplifyContext RAII base handling * Fix global static handling * Fix float32 tests * FIx gpu module * Support OpenMP "collapse" option * Add more collapse tests * Capture generics and statics * TraitVar handling * Python exceptions / isinstance [wip; no_ci] * clang-format * Add list comparison operators * Support empty raise in IR * Add dict 'or' operator * Fix repr * Add copy module * Fix spacing * Use sm_30 * Python exceptions * TypeTrait support; Fix defaultDict * Fix earlyDefines * Add defaultdict * clang-format * Fix invalid canonicalizations * Fix empty raise * Fix copyright * Add Python numerics option * Support py-numerics in math module * Update docs * Add static Python division / modulus * Add static py numerics tests * Fix staticrange/tuple; Add KwTuple.__getitem__ * clang-format * Add gpu parameter to par * Fix globals * Don't init loop vars on loop collapse * Add par-gpu tests * Update gpu docs * Fix isinstance check * Remove invalid test * Add -libdevice to set custom path [skip ci] * Add release notes; bump version [skip ci] * Add libdevice docs [skip ci] Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>
2022-09-16 03:40:00 +08:00
result = self.__copy__()
2021-09-28 02:02:44 +08:00
result |= other
return result
GPU and other updates (#52) * Add nvptx pass * Fix spaces * Don't change name * Add runtime support * Add init call * Add more runtime functions * Add launch function * Add intrinsics * Fix codegen * Run GPU pass between general opt passes * Set data layout * Create context * Link libdevice * Add function remapping * Fix linkage * Fix libdevice link * Fix linking * Fix personality * Fix linking * Fix linking * Fix linking * Add internalize pass * Add more math conversions * Add more re-mappings * Fix conversions * Fix __str__ * Add decorator attribute for any decorator * Update kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Remove old decorator * Fix pointer calc * Fix fill-in codegen * Fix linkage * Add comment * Update list conversion * Add more conversions * Add dict and set conversions * Add float32 type to IR/LLVM * Add float32 * Add float32 stdlib * Keep required global values in PTX module * Fix PTX module pruning * Fix malloc * Set will-return * Fix name cleanup * Fix access * Fix name cleanup * Fix function renaming * Update dimension API * Fix args * Clean up API * Move GPU transformations to end of opt pipeline * Fix alloc replacements * Fix naming * Target PTX 4.2 * Fix global renaming * Fix early return in static blocks; Add __realized__ function * Format * Add __llvm_name__ for functions * Add vector type to IR * SIMD support [wip] * Update kernel naming * Fix early returns; Fix SIMD calls * Fix kernel naming * Fix IR matcher * Remove module print * Update realloc * Add overloads for 32-bit float math ops * Add gpu.Pointer type for working with raw pointers * Add float32 conversion * Add to_gpu and from_gpu * clang-format * Add f32 reduction support to OpenMP * Fix automatic GPU class conversions * Fix conversion functions * Fix conversions * Rename self * Fix tuple conversion * Fix conversions * Fix conversions * Update PTX filename * Fix filename * Add raw function * Add GPU docs * Allow nested object conversions * Add tests (WIP) * Update SIMD * Add staticrange and statictuple loop support * SIMD updates * Add new Vec constructors * Fix UInt conversion * Fix size-0 allocs * Add more tests * Add matmul test * Rename gpu test file * Add more tests * Add alloc cache * Fix object_to_gpu * Fix frees * Fix str conversion * Fix set conversion * Fix conversions * Fix class conversion * Fix str conversion * Fix byte conversion * Fix list conversion * Fix pointer conversions * Fix conversions * Fix conversions * Update tests * Fix conversions * Fix tuple conversion * Fix tuple conversion * Fix auto conversions * Fix conversion * Fix magics * Update tests * Support GPU in JIT mode * Fix GPU+JIT * Fix kernel filename in JIT mode * Add __static_print__; Add earlyDefines; Various domination bugfixes; SimplifyContext RAII base handling * Fix global static handling * Fix float32 tests * FIx gpu module * Support OpenMP "collapse" option * Add more collapse tests * Capture generics and statics * TraitVar handling * Python exceptions / isinstance [wip; no_ci] * clang-format * Add list comparison operators * Support empty raise in IR * Add dict 'or' operator * Fix repr * Add copy module * Fix spacing * Use sm_30 * Python exceptions * TypeTrait support; Fix defaultDict * Fix earlyDefines * Add defaultdict * clang-format * Fix invalid canonicalizations * Fix empty raise * Fix copyright * Add Python numerics option * Support py-numerics in math module * Update docs * Add static Python division / modulus * Add static py numerics tests * Fix staticrange/tuple; Add KwTuple.__getitem__ * clang-format * Add gpu parameter to par * Fix globals * Don't init loop vars on loop collapse * Add par-gpu tests * Update gpu docs * Fix isinstance check * Remove invalid test * Add -libdevice to set custom path [skip ci] * Add release notes; bump version [skip ci] * Add libdevice docs [skip ci] Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>
2022-09-16 03:40:00 +08:00
def __repr__(self):
return f"Counter({super().__repr__()})"
2022-02-16 23:51:16 +08:00
def __dict_do_op_throws__(self, key: T, other: Z, op: F, F: type, Z: type):
self.__dict_do_op__(key, other, 0, op)
2022-02-16 23:51:16 +08:00
def _del_non_positives(self):
for k, v in self.items():
if v <= 0:
del self[k]
2021-09-28 02:02:44 +08:00
@extend
class Dict:
2022-02-16 23:51:16 +08:00
def __init__(self: Dict[K, int], other: Counter[K]):
2021-09-28 02:02:44 +08:00
self._init_from(other)
GPU and other updates (#52) * Add nvptx pass * Fix spaces * Don't change name * Add runtime support * Add init call * Add more runtime functions * Add launch function * Add intrinsics * Fix codegen * Run GPU pass between general opt passes * Set data layout * Create context * Link libdevice * Add function remapping * Fix linkage * Fix libdevice link * Fix linking * Fix personality * Fix linking * Fix linking * Fix linking * Add internalize pass * Add more math conversions * Add more re-mappings * Fix conversions * Fix __str__ * Add decorator attribute for any decorator * Update kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Fix kernel decorator * Remove old decorator * Fix pointer calc * Fix fill-in codegen * Fix linkage * Add comment * Update list conversion * Add more conversions * Add dict and set conversions * Add float32 type to IR/LLVM * Add float32 * Add float32 stdlib * Keep required global values in PTX module * Fix PTX module pruning * Fix malloc * Set will-return * Fix name cleanup * Fix access * Fix name cleanup * Fix function renaming * Update dimension API * Fix args * Clean up API * Move GPU transformations to end of opt pipeline * Fix alloc replacements * Fix naming * Target PTX 4.2 * Fix global renaming * Fix early return in static blocks; Add __realized__ function * Format * Add __llvm_name__ for functions * Add vector type to IR * SIMD support [wip] * Update kernel naming * Fix early returns; Fix SIMD calls * Fix kernel naming * Fix IR matcher * Remove module print * Update realloc * Add overloads for 32-bit float math ops * Add gpu.Pointer type for working with raw pointers * Add float32 conversion * Add to_gpu and from_gpu * clang-format * Add f32 reduction support to OpenMP * Fix automatic GPU class conversions * Fix conversion functions * Fix conversions * Rename self * Fix tuple conversion * Fix conversions * Fix conversions * Update PTX filename * Fix filename * Add raw function * Add GPU docs * Allow nested object conversions * Add tests (WIP) * Update SIMD * Add staticrange and statictuple loop support * SIMD updates * Add new Vec constructors * Fix UInt conversion * Fix size-0 allocs * Add more tests * Add matmul test * Rename gpu test file * Add more tests * Add alloc cache * Fix object_to_gpu * Fix frees * Fix str conversion * Fix set conversion * Fix conversions * Fix class conversion * Fix str conversion * Fix byte conversion * Fix list conversion * Fix pointer conversions * Fix conversions * Fix conversions * Update tests * Fix conversions * Fix tuple conversion * Fix tuple conversion * Fix auto conversions * Fix conversion * Fix magics * Update tests * Support GPU in JIT mode * Fix GPU+JIT * Fix kernel filename in JIT mode * Add __static_print__; Add earlyDefines; Various domination bugfixes; SimplifyContext RAII base handling * Fix global static handling * Fix float32 tests * FIx gpu module * Support OpenMP "collapse" option * Add more collapse tests * Capture generics and statics * TraitVar handling * Python exceptions / isinstance [wip; no_ci] * clang-format * Add list comparison operators * Support empty raise in IR * Add dict 'or' operator * Fix repr * Add copy module * Fix spacing * Use sm_30 * Python exceptions * TypeTrait support; Fix defaultDict * Fix earlyDefines * Add defaultdict * clang-format * Fix invalid canonicalizations * Fix empty raise * Fix copyright * Add Python numerics option * Support py-numerics in math module * Update docs * Add static Python division / modulus * Add static py numerics tests * Fix staticrange/tuple; Add KwTuple.__getitem__ * clang-format * Add gpu parameter to par * Fix globals * Don't init loop vars on loop collapse * Add par-gpu tests * Update gpu docs * Fix isinstance check * Remove invalid test * Add -libdevice to set custom path [skip ci] * Add release notes; bump version [skip ci] * Add libdevice docs [skip ci] Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>
2022-09-16 03:40:00 +08:00
class defaultdict(Dict[K,V]):
default_factory: S
K: type
V: type
S: TypeVar[Callable[[], V]]
def __init__(self: defaultdict[K, VV, Function[[], V]], VV: TypeVar[V]):
super().__init__()
self.default_factory = lambda: VV()
def __init__(self, f: S):
super().__init__()
self.default_factory = f
def __init__(self: defaultdict[K, VV, Function[[], V]], VV: TypeVar[V], other: Dict[K, V]):
super().__init__(other)
self.default_factory = lambda: VV()
def __init__(self, f: S, other: Dict[K, V]):
super().__init__(other)
self.default_factory = f
def __missing__(self, key: K):
default_value = self.default_factory()
self.__setitem__(key, default_value)
return default_value
def __getitem__(self, key: K) -> V:
if key not in self:
return self.__missing__(key)
return super().__getitem__(key)
def __dict_do_op_throws__(self, key: K, other: Z, op: F, F: type, Z: type):
x = self._kh_get(key)
if x == self._kh_end():
self.__missing__(key)
x = self._kh_get(key)
self._vals[x] = op(self._vals[x], other)
def copy(self):
d = defaultdict[K,V,S](self.default_factory)
d._init_from(self)
return d
def __copy__(self):
return self.copy()
def __deepcopy__(self):
d = defaultdict[K,V,S](self.default_factory)
for k,v in self.items():
d[k.__deepcopy__()] = v.__deepcopy__()
return d
def __eq__(self, other: defaultdict[K,V,S]) -> bool:
if self.__len__() != other.__len__():
return False
for k, v in self.items():
if k not in other or other[k] != v:
return False
return True
def __ne__(self, other: defaultdict[K,V,S]) -> bool:
return not (self == other)
def __repr__(self):
return f"defaultdict(<default factory of '{V.__name__}'>, {super().__repr__()})"
@extend
class Dict:
def __init__(self: Dict[K, V], other: defaultdict[K, V, S], S: type):
self._init_from(other)
Typechecker refactoring (#20) * Initial refactor commit * Support external vars * Simplify refactor; Python scoping [wip] * Python scoping [wip] * Python scoping [fix loops; wip] * Fix lambdas * Python scoping [test fixes; wip] * Fix scoping [wip] * Fix basic tests [no-ci] * Fix tests * CallExpr refactoring [wip] * CallExpr refactoring [wip] * Remove activeUnbounds tracking * Add core.codon * Move Function and other core types to core.codon; Revamp Function and Callable types * Refactor IntExpr, FloatExpr and CallExpr * Refactor ClassStmt * Refactor context, IdExpr and DotExpr * Refactor DotExpr and AssignStmt * Refactor ImportStmt * Refactor FunctionStmt * Refactor * Remove UpdateStmt * Refactor AssignReplacementVisitor * Make SimplifyVisitor in-place * Fix new scoping * Fix import type alias handling * Add docstrings; Complete Simplify refactoring * Fixes for seqtest * Refactor typecheck [wip] * Refactor typecheck [wip] * Refactor typecheck/access; Remove void anduse NoneType; Fix #18 * Refactor typecheck/assign * clang-format and cmake-format * Fix none types in IR * Multi-error support in simplify * Fix IR tests for new void * Simplify ClassStmt * Refactor cond.cpp * Refactor error.cpp * Refactor function.cpp and simplify unbounds * Refactor op.cpp * Refactor call.cpp [wip] [no-ci] * seqassertn updates [noci] * Refactor call.cpp * Refactor call.cpp * Refactor call.cpp * Refactor typecheck * clang-tidy updates [noci] * Refactor infer.cpp [wip] * Refactor infer.cpp * Refactor wrapExpr * Remove visitedAsts * Remove old base logic * Refactor typecheck ctx * Fix JIT bug * Fix JIT tests * Scoping fixes [wip] [noci] * Fix ImperativeForFlow var store * Add newlines [noci] * Dump IR module with log flag * Fix scoping bugs; Add &, ^ and | static operations; Address stylistic review issues * Fix side effect analysis for for-loops * Add support for class variables and ClassVar * Refactor special dot-member cases * Add codon app tests * Fix class variables; clang-tidy * Fix __argv__ * Add datetime constants and update tests * Fix #25; Add Py_None, Py_True and Py_False; External var support [wip] * External var support [wip] * Dump LLVM IR when debug flags are active * clang-format * Fix arg var construction * Extern var fixes * Undo extern var changes related to stdout etc. * Fix tuple magics * Fix extern vars and tuple magics * Fix duplicate var name error * Fix extern vars * Fix #16 * Fix side-effect analysis for try-catch * Move test C var to test executable * Add staticmethod * Fix var status for try-catch * Fix tests * Fix shell var name * Fix test * Fix app test * Fix scoping issue (remove dominated identifier from stack) * Fix no-pie issue * Use PIC when building library object * Don't use -no-pie when building library [noci] * Use -relocation-model=pic in test * Fix lib build on Linux * Fix lib build * Update exceptions to use subclasses vs. header * Fix __repr__ * Fix tests * Fix exceptions test * Don't build docs Co-authored-by: A. R. Shajii <ars@ars.me>
2022-07-27 04:06:00 +08:00
def namedtuple(name: Static[str], args): # internal
2021-09-28 02:02:44 +08:00
pass