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
| from __future__ import annotations | |
| import ctypes as ct | |
| class Point(ct.Structure): | |
| _fields_: list[tuple[str, ct._SimpleCData]] = [("x", ct.c_int), ("y", ct.c_int)] | |
| def __repr__(self) -> str: | |
| return f"({self.x}, {self.y})" |
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
| import inspect | |
| def foo(bar) -> str | None: | |
| bar_name: str = [ | |
| name | |
| for name, obj in inspect.currentframe().f_back.f_locals.items() | |
| if obj is bar | |
| ][0] | |
| return bar_name |
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
| import functools | |
| import sys | |
| from typing import Any, Callable, TypeVar | |
| T = TypeVar("T") | |
| def reveal_type[T](obj: T, /) -> T: | |
| print(f"Runtime type is {type(obj).__name__!r}", file=sys.stderr) | |
| return obj |
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
| 0 0 RESUME 0 | |
| 1 2 LOAD_CONST 0 (0) | |
| 4 LOAD_CONST 1 (None) | |
| 6 IMPORT_NAME 0 (functools) | |
| 8 STORE_NAME 0 (functools) | |
| 2 10 LOAD_CONST 0 (0) | |
| 12 LOAD_CONST 1 (None) | |
| 14 IMPORT_NAME 1 (sys) |
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
| let fib n = | |
| let rec aux acc n2 n1 = function | |
| | 1 -> acc | |
| | c -> aux ((n2 + n1) :: acc) n1 (n2 + n1) (c - 1) | |
| in | |
| List.rev(aux [1; 0] 0 1 (n - 1)) | |
| ;; | |
| let () = | |
| let fibs = fib 50 in |
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
| (Get-History -Count 1 | Select-Object -Property @{Name = 'ts'; Expression = { $_.EndExecutionTime - $_.StartExecutionTime} }).ts.ToString() |
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
| import asyncio | |
| import concurrent.futures | |
| import functools | |
| import os | |
| import threading | |
| import time | |
| import weakref | |
| from typing import Any, Callable, Optional, TypeVar | |
| _threads_queues = weakref.WeakKeyDictionary() |
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
| from typing import TypeVar | |
| T = TypeVar("T", int, slice) | |
| class BitVector: | |
| """A class for manipulating bits in a vector.""" | |
| _val: int |
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
| from collections.abc import Callable | |
| from threading import Lock | |
| from typing import Concatenate | |
| my_lock = Lock() | |
| def with_lock[**P, R](f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]: | |
| """A type-safe decorator which provides a lock.""" |
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 <stdbool.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #define MAX_BLOCKS 10 | |
| #define BLOCK_SIZE 1024 | |
| typedef struct { | |
| char *block; |