TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #309 · 2 фев.

Метод строки split() разделяет строку на несколько строк по указанному символу >>> "a_b_c".split('_') ['a', 'b', 'c'] Можно указать максимальное количество разделений >>> "a_b_c".split('_', 1) ['a', 'b_c'] Или резать с другой стороны с помощью rsplit() (right split) >>> "a_b_c".rsplit('_', 1) ['a_b', 'c'] А что будет если оставить аргументы пустыми? >>> "a_b_c".split() ['a_b_c'] Получаем список с одним элементом, потому что по умолчанию используется пробельный символ. >>> "a b c".split() ['a', 'b', 'c'] То есть это равнозначно такому вызову? >>> "a b c".split(" ") ['a', 'b', 'c'] Кажется да, но нет! Давайте попробуем добавить пробелов между буквами >>> "a b c".split(" ") ['a', '', '', 'b', '', '', 'c'] И вот картина уже не так предсказуема 😕 А вот что будет по умолчанию >>> "a b c".split() ['a', 'b', 'c'] Всё снова красиво! 🤩 По умолчанию в качестве разделителя используется любой пробельный символ, будь то табуляция или новая строка. Включая несколько таких символов идущих подряд. А также игнорируются пробельные символы по краям строки. >>> "a\t b\n c ".split() ['a', 'b', 'c'] Аналогичный способ можно собрать с помощью регулярного выражения. Но пробелы по краям строки придется обрабатывать дополнительно. >>> import re >>> re.split(r"\s+", ' a b c '.strip()) ['a', 'b', 'c'] Здесь тоже можно указать количество разделений >>> re.split(r"\s+", 'a b c', 1) ['a', 'b c'] А что если мы хотим написать красиво, то есть split() без аргументов, но при этом указать количество разделений? В этом случае первым аргументом передаём None >>> "a\n b c".split(None, 1) ['a', 'b c'] Данный метод не учитывает строки с пробелами, взятые в кавычки 'a "b c" '.split() ['a', '"b', 'c"'] Но для таких случаев есть другие способы. #tricks#basic

Резултати

Пронајдени 3 слични објави

Пребарај: #quantization

当前筛选 #quantization清除筛选
GitHub Trends

@githubtrending · Post #14747 · 25.05.2025 г., 11:30

#python#deep_learning#intel#machine_learning#neural_network#pytorch#quantization Intel Extension for PyTorch boosts the speed of PyTorch on Intel hardware, including both CPUs and GPUs, by using special features like AVX-512, AMX, and XMX for faster calculations[5][2][4]. It supports many popular large language models (LLMs) such as Llama, Qwen, Phi, and DeepSeek, offering optimizations for different data types and easy GPU acceleration. This means you can run advanced AI models much faster and more efficiently on your Intel computer, with simple setup and support for both ready-made and custom models. https://github.com/intel/intel-extension-for-pytorch

GitHub Trends

@githubtrending · Post #15091 · 24.08.2025 г., 11:30

#python#comfyui#diffusion#flux#genai#mlsys#quantization Nunchaku is a fast and efficient engine that runs 4-bit neural networks using a special method called SVDQuant, which compresses models to use less memory and speed up processing by 2 to 5 times compared to older methods. It supports advanced AI models for tasks like high-quality text-to-image generation and image editing, working best on modern NVIDIA GPUs. You can easily install and use it with ComfyUI, and it has active community support on Slack, Discord, and WeChat. This means you can generate or edit images quickly with less computing power, saving time and resources. It also offers tutorials and example workflows to help you get started smoothly. https://github.com/nunchaku-tech/ComfyUI-nunchaku

GitHub Trends

@githubtrending · Post #15385 · 02.01.2026 г., 12:30

#python#deep_learning#inference#openai#quantization#speech_recognition#speech_to_text#transformer#whisper Faster-Whisper is a fast version of OpenAI's Whisper that transcribes audio up to 4x quicker with the same accuracy, using less memory on CPU or GPU—benchmarks show it beats original Whisper (e.g., 1m03s vs 2m23s for 13-min audio on GPU). Install via `pip install faster-whisper`, no FFmpeg needed, and use simple Python code like `WhisperModel("large-v3").transcribe("audio.mp3")` for segments with timestamps. You benefit by getting quick, efficient speech-to-text for real-time apps, saving time and resources on long files or batches. https://github.com/SYSTRAN/faster-whisper