diff --git "a/AI/\344\275\277\347\224\250 GPT-4\343\200\201Python \345\222\214 Langchain\357\274\214\346\236\204\345\273\272\346\227\245\350\257\255\346\261\211\345\255\227\346\212\275\350\256\244\345\215\241\345\272\224\347\224\250\347\250\213\345\272\217.md" "b/AI/\344\275\277\347\224\250 GPT-4\343\200\201Python \345\222\214 Langchain\357\274\214\346\236\204\345\273\272\346\227\245\350\257\255\346\261\211\345\255\227\346\212\275\350\256\244\345\215\241\345\272\224\347\224\250\347\250\213\345\272\217.md" new file mode 100644 index 0000000..2426081 --- /dev/null +++ "b/AI/\344\275\277\347\224\250 GPT-4\343\200\201Python \345\222\214 Langchain\357\274\214\346\236\204\345\273\272\346\227\245\350\257\255\346\261\211\345\255\227\346\212\275\350\256\244\345\215\241\345\272\224\347\224\250\347\250\213\345\272\217.md" @@ -0,0 +1,233 @@ +原文:[Building a Japanese Kanji Flashcard App](https://adilmoujahid.com/posts/2023/10/kanji-gpt4/) + +--- + +# 使用 GPT-4、Python 和 Langchain,构建日语汉字抽认卡应用程序 + +近几个月来,GPT-4 吸引了主流的关注,ChatGPT 等应用程序展示了其广泛的功能,并为技术的代际转变奠定了基础。可以通过 API 以编程方式访问 GPT-4 模型,从而能够创建具有丰富的上下文相关数据的多样化应用程序。这篇博文旨在揭开利用 GPT-4 构建应用程序的过程的神秘面纱。我们将通过逐步开发日语汉字抽认卡应用程序来探索这一点,使用 GPT-4 来构建该应用程序并为其提供有价值的数据。 + +随着我们的步步推进,我们将探索学习日语汉字的挑战,利用 ChatGPT 构建前端,利用 GPT-4 的数据生成逻辑动态获取和格式化汉字数据,最终将其整合为一个使用 Python 和 Flask 的统一应用程序。 + +您可以在下面的动画 GIF 中查看最终成果,并在[此 GitHub 存储库](https://github.com/adilmoujahid/kanji-flashcard-app-gpt4)中找到该项目的源代码。 + +![](https://adilmoujahid.com/images/kanji-gpt4/kanji-gpt4.gif) + + +# 1. 定义用例 + +当学生开始踏上日语学习的旅程时,他们会遇到一个迷人而复杂的书写系统,由三种文字组成:平假名、片假名和汉字。例如,短语“東京タワーは高いです。”(Tōkyō Tawā wa takai desu),其中“東京”(东京)是汉字,“タワー”(塔)是片假名,连接语法是平假名。这句话翻译过来就是“东京塔很高”。各种文字组合在一起,它们具有不同的功能——汉字用于大多数名词、动词和形容词,片假名用于外来词和借用词,平假名主要用于语法功能 —— 这是日语书面语言的一个显着特征。 + +![](https://adilmoujahid.com/images/kanji-gpt4/hiragana-katakana-kanji.png) + +平假名和片假名各有 46 个基本字符,属于注音文字,而汉字是由中国汉字改编而成的,具有含义,并且通常有多种读法。虽然汉字字符有数以万计个,但日本的一般识字能力围绕着 2,136 个字符进行,如[Joyo Kanji List](https://en.wikipedia.org/wiki/List_of_j%C5%8Dy%C5%8D_kanji) 所定义。 + +在下表中,您可以看到平假名和片假名字符及其相应读法。在每个框中,平假名字符显示在左侧,片假名字符显示在右侧。 + + +![](https://adilmoujahid.com/images/kanji-gpt4/hiragana-katakana-list.png) + +下面您可以看到汉字字符的一小部分示例。 + +![](https://adilmoujahid.com/images/kanji-gpt4/kanji-sample.png) + +为了解决日语汉字学生面临的挑战,我们的目标是构建一个由 GPT-4 功能支持的汉字抽认卡应用程序,以促进学习之旅。该应用程序充当动态学习伴侣,使用户能够用自然语言指定他们希望探索的特定汉字。利用 GPT-4 的强大功能,该应用程序会自动整理符合用户明确需求的汉字列表,并通过提供单词的多项选择阅读来进一步评估他们的能力,确保提供积极有效的学习体验。 + +# 2. 构建前端 + +我们的下一步是为我们的汉字抽认卡应用程序构建前端,我们将在第 4 节中将其与 GPT-4 API 集成在一起。为了实现这一目标,我们将采用 ChatGPT,利用 GPT-4 模型,并应用以下提示生成我们前端的 HTML/CSS/JS 代码。 + +``` +Develop a flashcard app to facilitate the study of Japanese Kanji, utilizing HTML, JavaScript, and CSS for implementation. The app should have the following functionalities: +1- Upon launching, the app presents a Japanese word in Kanji, accompanied by four buttons containing Hiragana readings: one correct and three incorrect options. +2- When the user selects an answer, the corresponding button should be highlighted in green if it's correct, and in red if it's wrong, while also highlighting the correct button in green. +3- Once an answer is selected, the app should display the English translation of the word, present the word within the context of a Japanese sentence, and also provide its English translation. +4- Include a button to transition to the subsequent word. +5- Populate the app with 10 different words in Kanji to test the app. The incorrect options should also be realistic and relevant to the correct answer. +6- Make sure the app is centered on the screen and use simple styling. + +``` + +下面的 gif 显示了完全使用 ChatGPT 制作的前端。这一令人印象深刻的结果证明了 GPT-4 能够简化开发流程并使其更易于使用,即使对于那些前端经验有限的人来说也是如此。 + +![](https://adilmoujahid.com/images/kanji-gpt4/kanji_UI_1.gif) + + +# 3. 构建数据生成逻辑 + +在本节中,我们将使用 GPT-4 构建日语汉字学习抽认卡应用程序的后端逻辑。该后端将负责获取和格式化汉字数据。为了实现这一目标,我们将结合使用 Python 和 LangChain。LangChain 是一个专门的框架,旨在创建由大型语言模型(包括来自 OpenAI 的模型)驱动的应用程序。它提供了与 API 接口交互、制作提示和构建返回输出的各种抽象。 + +我们将从导入必要的库开始。在 Langchain 中,我们特别需要 `ChatOpenAI` 来与 GPT-4 进行通信,以及 `ChatPromptTemplate` 为我们的用例创建提示模板。 + +```py +import os +from langchain.chat_models import ChatOpenAI +from langchain.prompts import ChatPromptTemplate + +``` +接下来,我们指定要部署的模型(“gpt-4-0613”)。确保正确配置我们的 API 密钥至关重要。完成此操作后,我们与 GPT-4 建立连接。有关可用 OpenAI API 的完整列表,请访问[此处](https://platform.openai.com/account/rate-limits)。有关 API 的详细信息以及获取API 密钥的说明,您可以参考 [此链接](https://openai.com/product)。 + +```py +llm_model = "gpt-4-0613" +OPENAI_API_KEY = openai_API_key +os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY + +chat = ChatOpenAI(temperature=1, model=llm_model) +``` +接下来,我们构建一个专门针对我们的要求设计的 Langchain 模板。将 Langchain 模板视为预定义的表单。这些表单允许我们构建 GPT-4 的提示,其中包含我们希望在发送请求之前设置的特定变量。出于此目的,该模板将包含旨在检索和格式化汉字单词以及附加数据的提示。在本例中,我们的变量用 `{description}` 表示,它将表示我们感兴趣的汉字的具体描述。 + + + +```py +string_template = """Give 2 words written in Kanji that are: ```{description}```, \ +accompanied with its correct Hiragana reading and three incorrect Hiragana readings \ +that are realistic and relevant to the correct answer. \ +Also give me the English translation of the word, and present the word within the context \ +of a Japanese sentence, and also provide its English translation. + +Format the output as JSON with the data represented as an array of dictionaries with the following keys: +"word": str // Japanese word written in Kanji +"correct": str // Correct reading of the Kanji word in Hiragana +"incorrect": List[str] //Incorrect readings of the Kanji phrase +"english": str // English translation of the Kanji word +"sentenceJP": str // Example sentence in Japanese using the Kanji word +"sentenceEN": str // English translation of the example sentence +""" + +prompt_template = ChatPromptTemplate.from_template(string_template) +``` + +有了我们手头的模板,我们就可以从 GPT-4 中检索汉字单词,例如,询问与经济学相关的汉字。 + +```py +description_example = "related to Economics" +kanji_request = prompt_template.format_messages(description=description_example) + +kanji_response = chat(kanji_request) +print(kanji_response.content) + +``` + +在本例中,我们收到了一个结构良好的 JSON。但是,如果响应与我们所需的格式不匹配,Langchain 会提供各种[输出解析器](https://python.langchain.com/docs/modules/model_io/output_parsers/)来帮助我们相应地调整输出。 + + +```py +[ + { + "word": "経済", + "correct": "けいざい", + "incorrect": ["けいせい", "えいざい", "けんざい"], + "english": "economics", + "sentenceJP": "経済の状況を理解するためのデータが必要です。", + "sentenceEN": "We need data to understand the economic situation." + }, + { + "word": "財政", + "correct": "ざいせい", + "incorrect": ["さいせい", "ざいぜい", "ざいしょう"], + "english": "finance", + "sentenceJP": "政府は財政問題に対応するための新たな策を立てます。", + "sentenceEN": "The government will devise new measures to deal with financial problems." + } +] + +``` + +# 4. 整一块 + +数据生成准备就绪后,我们现在需要将其连接到我们的前端。我们将为此使用 Flask。Flask 会将我们的数据生成逻辑转变为 API,并管理我们的前端。代码很短,不到 50 行,有两条主要路由:服务前端的根路由 `(/)` 和根据前端输入调用数据生成逻辑并以 JSON 格式返回汉字数据的路由 `/get_words`。 + +```py +import os +import json +from config import * +from langchain.chat_models import ChatOpenAI +from langchain.prompts import ChatPromptTemplate +from flask import Flask, render_template, request, jsonify + +app = Flask(__name__) + +llm_model = "gpt-4-0613" +OPENAI_API_KEY = openai_API_key +os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY + +chat = ChatOpenAI(temperature=1, model=llm_model) + + +string_template = """Give 2 words written in Kanji that are: ```{description}```, \ +accompanied with its correct Hiragana reading and three incorrect Hiragana readings \ +that are realistic and relevant to the correct answer. \ +Also give me the English translation of the word, and present the word within the context \ +of a Japanese sentence, and also provide its English translation. + +Format the output as JSON with the data represented as an array of dictionaries with the following keys: +"word": str // Japanese word written in Kanji +"correct": str // Correct reading of the Kanji word in Hiragana +"incorrect": List[str] //Incorrect readings of the Kanji phrase +"english": str // English translation of the Kanji word +"sentenceJP": str // Example sentence in Japanese using the Kanji word +"sentenceEN": str // English translation of the example sentence +""" + +prompt_template = ChatPromptTemplate.from_template(string_template) + +@app.route('/') +def home(): + return render_template('index.html') + +@app.route('/get_words', methods=['POST']) +def get_word(): + description = request.json.get('description', '') + words_request = prompt_template.format_messages(description=description) + words_response = chat(words_request) + return jsonify(json.loads(words_response.content)) + +if __name__ == "__main__": + app.run(port=5000) +``` + +在前端方面,我们引入了一些细微的变化:一个输入字段和一个按钮,让用户能够指定他们希望探索的汉字类型,并附有一个指示数据检索过程的加载旋转器。 + +要启动应用程序,请从终端运行命令 `python app.py`,然后在您首选的浏览器中访问 http://127.0.0.1:5000。 + + +![](https://adilmoujahid.com/images/kanji-gpt4/kanji-gpt4.gif) + +# 5. 优化和扩展我们应用的一些想法 + +我们构建的应用程序功能齐全,非常适合学习汉字。尽管如此,我们仍然需要注意某些成本和性能方面的考虑。 + +### 成本 + +OpenAI 的定价模型根据 API 调用期间消耗的代币进行收费。截至撰写本文时: + +- GPT-4(8K 上下文)的输入价格为**每 1K 代币 0.03 美元**,输出**每 1K 代币价格为 0.06 美元**。 +- GPT-3.5 Turbo(4K 上下文)的输入价格为**每 1K 代币 0.0015 美元**,输出**每 1K 代币价格为 0.002 美元**。 +- 您可以在[此处](https://openai.com/pricing)找到 OpenAI 定价详细信息。 + +对于我们的特定场景,通过 GPT-4 获取和格式化 5 个汉字单词的提示使用大约 188 个输入标记和 176 个输出标记,这意味着总费用为 0.0162 美元。 + +要获取消耗的代币数量和美元成本,您可以执行以下代码: + +```py +from langchain.callbacks import get_openai_callback + +with get_openai_callback() as cb: + description_example = "related to Economics" + kanji_request = prompt_template.format_messages(description=description_example) + kanji_response = chat(kanji_request) + print(cb) + +``` + +虽然这种成本结构对于一些 API 调用来说似乎是可以接受的,但扩展应用程序以满足更大的用户群会增加这些费用。 + +### 执行时间 + +使用 GPT-4 获取并格式化 5 个汉字单词大约需要 17.2 秒。这种延迟会对用户体验产生负面影响。 + +为了有效地优化和扩展我们的应用程序,我们可以考虑一种将数据源与 GPT-4 API 调用相结合并简化提示和输出格式的方法。例如,我们可以从常用汉字列表中获取所有字符,并使用 GPT-4 进行一次性翻译和列举例句。然后,可以通过要求 GPT-4 获取与特定主题相关的汉字单词来简化提示,而无需翻译或句子示例。之后,我们可以将这些汉字与我们预先生成的句子进行匹配。此方法可能会加快执行时间并减少令牌使用。 + + +# 总结 + +总之,GPT-4 正在改变应用程序开发的游戏规则,尤其是在处理数据方面。我们的日语抽认卡应用程序展示了 GPT-4 有多么方便。开发人员可以使用 GPT-4 快速获取所需的信息,而不是手动收集数据。这不仅加快了构建过程,还确保应用程序充满有用的内容。借助 GPT-4 等工具,创建数据丰富的应用程序从未如此简单和高效。 \ No newline at end of file diff --git "a/AI/\346\236\204\345\273\272\344\270\200\344\270\252 AI \345\267\245\345\205\267\346\235\245\345\215\263\346\227\266\346\200\273\347\273\223\344\271\246\347\261\215.md" "b/AI/\346\236\204\345\273\272\344\270\200\344\270\252 AI \345\267\245\345\205\267\346\235\245\345\215\263\346\227\266\346\200\273\347\273\223\344\271\246\347\261\215.md" new file mode 100644 index 0000000..bdc127e --- /dev/null +++ "b/AI/\346\236\204\345\273\272\344\270\200\344\270\252 AI \345\267\245\345\205\267\346\235\245\345\215\263\346\227\266\346\200\273\347\273\223\344\271\246\347\261\215.md" @@ -0,0 +1,196 @@ +原文:[Build an AI Tool to Summarize Books Instantly](https://levelup.gitconnected.com/build-an-ai-tool-to-summarize-books-instantly-828680c1ceb4) + +--- +> 译注:总体思想就是分而治之 + +# 构建一个 AI 来即时总结书籍 + +> 无需从头到尾阅读,即可掌握任何一本书的要点。 + +在本文中,我们将使用 Python、Langchain 和 OpenAI Embeddings 构建一个简单但功能强大的书籍摘要器。 + +![](https://miro.medium.com/v2/resize:fit:1400/format:webp/1*DFqc1P6PnOZ8S95puZqSEg.png) ⬆️ 使用 DALL·E 3 生成。 + +# 挑战 + +像 GPT-3 和 GPT-4 这样的人工智能模型非常强大,但它们也有其局限性。一个重要的限制是上下文窗口,它限制了模型在任一时间可以考虑的文本量。这意味着,您不能只是将整本书输入到模型中就期望能够得到连贯的摘要。此外,处理大文本的成本可能会很高。 + +# 解决方案 + +为了克服这些挑战,我们设计了一种既经济又高效的方法。过程如下: + +# 简化流程 + +以下是我们如何将一本完整的书转化为简明摘要的方法: + +1. **分割和嵌入:**我们将书分解成更小的块,然后将它们转换为嵌入。这一步的成本令人惊讶。 +2. **聚类:** 接着,我们对这些嵌入进行聚类,以找到书中最具代表性的部分。 +3. **总结:** 然后,我们使用更具成本效益的 GPT-3.5 模型来总结这些关键部分。 +4. **组合摘要:** 最后,我们使用 GPT-4 将这些摘要拼接成一个流畅的叙述。 + +通过仅在最后一步使用 GPT-4 来设法保持较低的成本。 + +现在,让我们分解代码和每个步骤背后的基本原理。构建摘要器 + +让我们深入研究代码并逐步构建我们的摘要器。 + +# 步骤一:加载书籍 + +首先,我们需要读取书本内容。我们将支持 PDF 和 EPUB 格式。 + + +```py +import os +import tempfile +from langchain.document_loaders import PyPDFLoader, UnstructuredEPubLoader + +def load_book(file_obj, file_extension): + """Load the content of a book based on its file type.""" + text = "" + with tempfile.NamedTemporaryFile(delete=False, suffix=file_extension) as temp_file: + temp_file.write(file_obj.read()) + if file_extension == ".pdf": + loader = PyPDFLoader(temp_file.name) + pages = loader.load() + text = "".join(page.page_content for page in pages) + elif file_extension == ".epub": + loader = UnstructuredEPubLoader(temp_file.name) + data = loader.load() + text = "\n".join(element.page_content for element in data) + else: + raise ValueError(f"Unsupported file extension: {file_extension}") + os.remove(temp_file.name) + text = text.replace('\t', ' ') + return text +``` + +# 步骤二:分割和嵌入文本 + +AI 模型有令牌限制,这意味着它们不能一次处理一整本书。通过将文本分块,我们确保书中的每个部分都能够被喂给 AI。 + +我们将把文本分块并将其转换为嵌入。嵌入可以通过最少的计算快速将文本转换为紧凑的数字形式,从而使该过程既快速又经济高效。 + + +```py +from langchain.text_splitter import RecursiveCharacterTextSplitter +from langchain.embeddings import OpenAIEmbeddings + +def split_and_embed(text, openai_api_key): + text_splitter = RecursiveCharacterTextSplitter(separators=["\n\n", "\n", "\t"], chunk_size=10000, chunk_overlap=3000) + docs = text_splitter.create_documents([text]) + embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key) + vectors = embeddings.embed_documents([x.page_content for x in docs]) + return docs, vectors +``` + +# 步骤三:对嵌入进行聚类 + +我们使用 KMeans 聚类算法对相似的块进行分组。在我的版本中,正如您在下面所看到的,我发现对于大多数书籍来说,11 个簇就可以很好地工作。但您可以根据您的用例进行调整。 + +这里,我们将整本书分块,然后转化为嵌入。根据其相似性对这些嵌入进行分组。对于每个组,我们选择最具代表性的嵌入并将其映射回其相应的文本块。 + + +```py +from sklearn.cluster import KMeans +import numpy as np + +def cluster_embeddings(vectors, num_clusters): + kmeans = KMeans(n_clusters=num_clusters, random_state=42).fit(vectors) + closest_indices = [np.argmin(np.linalg.norm(vectors - center, axis=1)) for center in kmeans.cluster_centers_] + return sorted(closest_indices) +``` + +# 步骤四:总结代表性块 + +我们将使用 GPT-3.5 来只总结那些选定的块。 + + +```py +from langchain.chains.summarize import load_summarize_chain +from langchain.prompts import PromptTemplate + +def summarize_chunks(docs, selected_indices, openai_api_key): + llm3_turbo = ChatOpenAI(temperature=0, openai_api_key=openai_api_key, max_tokens=1000, model='gpt-3.5-turbo-16k') + map_prompt = """ + You are provided with a passage from a book. Your task is to produce a comprehensive summary of this passage. Ensure accuracy and avoid adding any interpretations or extra details not present in the original text. The summary should be at least three paragraphs long and fully capture the essence of the passage. + ```{text}``` + SUMMARY: + """ + map_prompt_template = PromptTemplate(template=map_prompt, input_variables=["text"]) + selected_docs = [docs[i] for i in selected_indices] + summary_list = [] + + for doc in selected_docs: + chunk_summary = load_summarize_chain(llm=llm3_turbo, chain_type="stuff", prompt=map_prompt_template).run([doc]) + summary_list.append(chunk_summary) + + return "\n".join(summary_list) +``` + +# 步骤五:创建最终摘要 + +我们使用 GPT-4 将各个摘要合并为一个有凝聚力的最终摘要。 + + +```py +from langchain.schema import Document +from langchain.chat_models import ChatOpenAI + +def create_final_summary(summaries, openai_api_key): + llm4 = ChatOpenAI(temperature=0, openai_api_key=openai_api_key, max_tokens=3000, model='gpt-4', request_timeout=120) + combine_prompt = """ + You are given a series of summarized sections from a book. Your task is to weave these summaries into a single, cohesive, and verbose summary. The reader should be able to understand the main events or points of the book from your summary. Ensure you retain the accuracy of the content and present it in a clear and engaging manner. + ```{text}``` + COHESIVE SUMMARY: + """ + combine_prompt_template = PromptTemplate(template=combine_prompt, input_variables=["text"]) + reduce_chain = load_summarize_chain(llm=llm4, chain_type="stuff", prompt=combine_prompt_template) + final_summary = reduce_chain.run([Document(page_content=summaries)]) + return final_summary +``` + +# 将它们放在一起 + +现在,我们将所有步骤合并到一个函数中,该函数接受上传的文件并生成摘要。 + + +```py +# ... (previous code for imports and functions) + +def generate_summary(uploaded_file, openai_api_key, num_clusters=11, verbose=False): + file_extension = os.path.splitext(uploaded_file.name)[1].lower() + text = load_book(uploaded_file, file_extension) + docs, vectors = split_and_embed(text, openai_api_key) + selected_indices = cluster_embeddings(vectors, num_clusters) + summaries = summarize_chunks(docs, selected_indices, openai_api_key) + final_summary = create_final_summary(summaries, openai_api_key) + return final_summary +``` + +# 测试总结器 + +最后,我们可以用一本书来测试我们的摘要器。 + + +```py +# Testing the summarizer +if __name__ == '__main__': + load_dotenv() + openai_api_key = os.getenv('OPENAI_API_KEY') + book_path = "path_to_your_book.epub" + with open(book_path, 'rb') as uploaded_file: + summary = generate_summary(uploaded_file, openai_api_key, verbose=True) + print(summary) +``` + +# 总结 + +这个工具可以帮助你快速理解任何书籍的要点。我们采取的方法不仅成本低廉,而且适用于具有任何长度的书籍。 + +请记住,摘要的质量取决于聚类和摘要提示,因此请随意根据您的需要进行调整。 + +您可以尝试 Streamlit 应用程序并在此处查看摘要器:[GPT Summarizer App](https://gptsummarizer.streamlit.app/)。 + +我希望这篇文章对您有所帮助。如果您有任何问题或反馈,请发表评论或联系我们。 + +搬砖快乐!:) diff --git "a/Machine Learning/\344\275\277\347\224\250 Python\357\274\214\345\260\206\345\210\206\346\236\220\346\225\260\346\215\256\351\200\237\345\272\246\346\217\220\351\253\230 170,000 \345\200\215.md" "b/Machine Learning/\344\275\277\347\224\250 Python\357\274\214\345\260\206\345\210\206\346\236\220\346\225\260\346\215\256\351\200\237\345\272\246\346\217\220\351\253\230 170,000 \345\200\215.md" new file mode 100644 index 0000000..26c0a9a --- /dev/null +++ "b/Machine Learning/\344\275\277\347\224\250 Python\357\274\214\345\260\206\345\210\206\346\236\220\346\225\260\346\215\256\351\200\237\345\272\246\346\217\220\351\253\230 170,000 \345\200\215.md" @@ -0,0 +1,721 @@ +原文:[Analyzing Data 170,000x Faster with Python](https://sidsite.com/posts/python-corrset-optimization/) + +--- + +# 使用 Python,将分析数据速度提高 170,000 倍 + + +这篇 [使用 Rust,将分析数据速度提高 180,000 倍](https://willcrichton.net/notes/k-corrset/)首先介绍了一些未优化的 Python 代码,然后展示了用 Rust 重写和优化代码的过程,从而实现了 180,000 倍的加速。作者指出: + + +> +> 有很多方法可以使 Python 代码更快,但本文的重点不是将高度优化的 Python 与高度优化的 Rust 进行比较。其重点是将“标准 Jupyter 笔记本”形式的 Python 与高度优化的 Rust 进行比较。 +> +> + +问题来了:如果我们坚持使用 Python,那么我们可以实现什么样的速度提升? + +在这篇文章中,我们将在 Python 中经历一次分析和迭代加速代码的旅程。 + + +#### 复制原始基准 + +这篇文章中的时间与原始文章中报告的时间相当。使用类似的计算机(M1 Macbook Pro),我测量得到: + +* 原始未优化代码的平均迭代时间为 35 毫秒,经过 1,000 多次迭代测量。原始文章则为 36 毫秒。 +* 对于完全优化的 Rust 代码,加速超过 180,081 倍,测量通过超过 5,000,000 次迭代完成。原始文章则为 182,450x。 + + +### Python 基线 + +下面是基线的一个副本,它是未优化的 Python 代码,来自这篇[文章](https://willcrichton.net/notes/k-corrset/)。 + +```py +from itertools import combinations +import pandas as pd +from pandas import IndexSlice as islice + +def k_corrset(data, K): + all_qs = data.question.unique() + q_to_score = data.set_index(['question', 'user']) + all_grand_totals = data.groupby('user').score.sum().rename('grand_total') + + # Inner loop + corrs = [] + for qs in combinations(all_qs, K): + qs_data = q_to_score.loc[islice[qs,:],:].swaplevel() + answered_all = qs_data.groupby(level=[0]).size() == K + answered_all = answered_all[answered_all].index + qs_totals = qs_data.loc[islice[answered_all,:]] \ + .groupby(level=[0]).sum().rename(columns={'score': 'qs'}) + r = qs_totals.join(all_grand_totals).corr().qs.grand_total + corrs.append({'qs': qs, 'r': r}) + corrs = pd.DataFrame(corrs) + + return corrs.sort_values('r', ascending=False).iloc[0].qs + +data = pd.read_json('scores.json') +print(k_corrset(data, K=5)) +``` + +这是 dataframe `data` 的前两行。 + + +| user | question | score | +| --- | --- | --- | +| e213cc2b-387e-4d7d-983c-8abc19a586b1 | d3bdb068-7245-4521-ae57-d0e9692cb627 | 1 | +| 951ffaee-6e17-4599-a8c0-9dfd00470cd9 | d3bdb068-7245-4521-ae57-d0e9692cb627 | 0 | + + +我们可以使用原始代码的输出来测试优化代码的正确性。 + +由于我们正在尝试优化内部循环,故而我们将内部循环放入其自己的函数中,以使用 [line_profiler](https://github.com/pyutils/line_profiler) 对其进行分析。 + + +```sh +Avg time per iteration: 35 ms +Speedup over baseline: 1.0x + +% Time Line Contents +===================== + def compute_corrs( + qs_iter: Iterable, q_to_score: pd.DataFrame, grand_totals: pd.DataFrame + ): + 0.0 result = [] + 0.0 for qs in qs_iter: + 13.5 qs_data = q_to_score.loc[islice[qs, :], :].swaplevel() + 70.1 answered_all = qs_data.groupby(level=[0]).size() == K + 0.4 answered_all = answered_all[answered_all].index + 0.0 qs_total = ( + 6.7 qs_data.loc[islice[answered_all, :]] + 1.1 .groupby(level=[0]) + 0.6 .sum() + 0.3 .rename(columns={"score": "qs"}) + ) + 7.4 r = qs_total.join(grand_totals).corr().qs.grand_total + 0.0 result.append({"qs": qs, "r": r}) + 0.0 return result +``` + +我们可以看到我们试图优化的值(平均迭代时间/加速比),以及每行花费的时间比例。 + +以下是优化代码的工作流程: + +* 运行分析器 +* 识别最慢的代码行 +* 试着让较慢的代码行快点 +* 重复 + +如果只有几行代码占据了大部分时间,我们就知道具体要关注什么,从上面我们看到有一行特别慢的代码,它占据了大约 70% 的时间。 + + +### 优化 1 - 包含回答问题的用户的集合字典,*users_who_answered_q* + +基线执行各种繁重的 Pandas 操作,以找出哪些用户回答了当前的一组问题 `qs`。特别是,它检查数据帧的每一行以找出哪些用户回答了问题。对于第一个优化,我们可以使用集合字典,而不是使用完整的数据帧。这让我们可以快速查找哪些用户回答了 `qs` 中的每个问题,并使用 Python 的集合交集来找出哪些用户回答了所有问题。 + + +```sh +Avg time per iteration: 10.0 ms +Speedup over baseline: 3.5x + +% Time Line Contents +===================== + def compute_corrs(qs_iter, users_who_answered_q, q_to_score, grand_totals): + 0.0 result = [] + 0.0 for qs in qs_iter: + 0.0 user_sets_for_qs = [users_who_answered_q[q] for q in qs] + 3.6 answered_all = set.intersection(*user_sets_for_qs) + 40.8 qs_data = q_to_score.loc[islice[qs, :], :].swaplevel() + 0.0 qs_total = ( + 22.1 qs_data.loc[islice[list(answered_all), :]] + 3.7 .groupby(level=[0]) + 1.9 .sum() + 1.1 .rename(columns={"score": "qs"}) + ) + 26.8 r = qs_total.join(grand_totals).corr().qs.grand_total + 0.0 result.append({"qs": qs, "r": r}) + 0.0 return result +``` + +这显着加快了计算行的速度 `answered_all`,从占用 70% 的时间降低到 4%,并且我们的速度已经比基线快了 3 倍以上。 + + +### 优化 2 - *score_dict* 字典 + +如果我们将用于计算 `qs_total` 的每行代码(包括 `qs_data` 这一行)的时间相加,则约为 65%;所以接下来要优化哪一个就很清楚了。我们可以再次通过快速字典查找来切换对整个数据集的繁重操作(索引、分组等)。我们引入了`score_dict`,这是一个字典,可以让我们查找给定问题和用户对的分数。 + + +```sh +Avg time per iteration: 690 μs +Speedup over baseline: 50.8x + +% Time Line Contents +===================== + def compute_corrs(qs_iter, users_who_answered_q, score_dict, grand_totals): + 0.0 result = [] + 0.0 for qs in qs_iter: + 0.1 user_sets_for_qs = [users_who_answered_q[q] for q in qs] + 35.9 answered_all = set.intersection(*user_sets_for_qs) + 3.4 qs_total = {u: sum(score_dict[q, u] for q in qs) for u in answered_all} + 8.6 qs_total = pd.DataFrame.from_dict(qs_total, orient="index", columns=["qs"]) + 0.1 qs_total.index.name = "user" + 51.8 r = qs_total.join(grand_totals).corr().qs.grand_total + 0.0 result.append({"qs": qs, "r": r}) + 0.0 return result +``` + +这使我们的速度提高了 50 倍。 + +### 优化 3 - *grand_totals* 字典和 np.corrcoef + + +上面最慢那一行做了几件事,它进行一个 Pandas join 操作,将 `grand_totals` 和 `qs_total` 组合在一起,然后计算其相关系数。同样,我们可以通过使用字典查找而不是 join 来提升速度,此外,由于我们不再使用 Pandas 对象,因此,我们使用 `np.corrcoef` 来代替 Pandas `corr`。 + + +```sh +Avg time per iteration: 380 μs +Speedup over baseline: 91.6x + +% Time Line Contents +===================== + def compute_corrs(qs_iter, users_who_answered_q, score_dict, grand_totals): + 0.0 result = [] + 0.0 for qs in qs_iter: + 0.2 user_sets_for_qs = [users_who_answered_q[q] for q in qs] + 83.9 answered_all = set.intersection(*user_sets_for_qs) + 7.2 qs_total = [sum(score_dict[q, u] for q in qs) for u in answered_all] + 0.5 user_grand_total = [grand_totals[u] for u in answered_all] + 8.1 r = np.corrcoef(qs_total, user_grand_total)[0, 1] + 0.1 result.append({"qs": qs, "r": r}) + 0.0 return result +``` + +这使我们的速度提高了约 90 倍。 + + +### 优化 4 - 将 uuid 字符串转换成整数 + +下一个优化完全不会更改内循环中的代码。但它确实提高了某些操作的速度。我们用更短的整数来替换长的用户/问题 uuid(例如, `e213cc2b-387e-4d7d-983c-8abc19a586b1`)。完成方法是: + + +```py +data.user = data.user.map({u: i for i, u in enumerate(data.user.unique())}) +data.question = data.question.map( + {q: i for i, q in enumerate(data.question.unique())} +) +``` + +然后进行评估: + +```sh +Avg time per iteration: 210 μs +Speedup over baseline: 168.5x + +% Time Line Contents +===================== + def compute_corrs(qs_iter, users_who_answered_q, score_dict, grand_totals): + 0.0 result = [] + 0.1 for qs in qs_iter: + 0.4 user_sets_for_qs = [users_who_answered_q[q] for q in qs] + 71.6 answered_all = set.intersection(*user_sets_for_qs) + 13.1 qs_total = [sum(score_dict[q, u] for q in qs) for u in answered_all] + 0.9 user_grand_total = [grand_totals[u] for u in answered_all] + 13.9 r = np.corrcoef(qs_total, user_grand_total)[0, 1] + 0.1 result.append({"qs": qs, "r": r}) + 0.0 return result +``` + +### 优化 5 - np.bool_ 数组取代用户集 + +我们可以看到上面的 set 操作仍然是最慢的一行。我们可以转为使用一个类型为 `np.bool_` 的用户数组来取代整数集,然后使用 `np.logical_and.reduce` 来查找那些回答了 `qs` 中所有问题的用户。(注意,虽然 `np.bool_` 中的每个元素都是一个完整的字节,但是 `np.logical_and.reduce` 仍然很快。)这带来了显著的速度提升: + + +```sh +Benchmark #6: NumPy bool_ array to identify users who answered qs +Using 1000 iterations... + +Avg time per iteration: 75 μs +Speedup over baseline: 466.7x + +% Time Line Contents +===================== + def compute_corrs(qs_iter, users_who_answered_q, score_dict, grand_totals): + 0.0 result = [] + 0.1 for qs in qs_iter: + 12.0 user_sets_for_qs = users_who_answered_q[qs, :] # numpy indexing + 9.9 answered_all = np.logical_and.reduce(user_sets_for_qs) + 10.7 answered_all = np.where(answered_all)[0] + 33.7 qs_total = [sum(score_dict[q, u] for q in qs) for u in answered_all] + 2.6 user_grand_total = [grand_totals[u] for u in answered_all] + 30.6 r = np.corrcoef(qs_total, user_grand_total)[0, 1] + 0.2 result.append({"qs": qs, "r": r}) + 0.0 return result +``` + +### 优化 6 - *score_matrix* 代替 dict + +上面最慢的一行现在是计算 `qs_total` 了。按照原始文章中的例子,我们改用一个密集的 np.array 来查找分数,而不是使用字典,然后使用快速的 NumPy 索引来获取分数。 + +```sh +Avg time per iteration: 56 μs +Speedup over baseline: 623.7x + +% Time Line Contents +===================== + def compute_corrs(qs_iter, users_who_answered_q, score_matrix, grand_totals): + 0.0 result = [] + 0.2 for qs in qs_iter: + 16.6 user_sets_for_qs = users_who_answered_q[qs, :] + 14.0 answered_all = np.logical_and.reduce(user_sets_for_qs) + 14.6 answered_all = np.where(answered_all)[0] + 7.6 qs_total = score_matrix[answered_all, :][:, qs].sum(axis=1) + 3.9 user_grand_total = [grand_totals[u] for u in answered_all] + 42.7 r = np.corrcoef(qs_total, user_grand_total)[0, 1] + 0.4 result.append({"qs": qs, "r": r}) + 0.0 return result +``` + +### 优化 7 - 自定义 *corrcoef* + +上面最慢的一行是 `np.corrcoef`……我们将尽一切努力来优化我们的代码,所以这是我们自己实现的 corrcoef,对于这个用例来说,它带来了两杯的速度提升: + +```py +def corrcoef(a: list[float], b: list[float]) -> float | None: + """same as np.corrcoef(a, b)[0, 1]""" + n = len(a) + sum_a = sum(a) + sum_b = sum(b) + sum_ab = sum(a_i * b_i for a_i, b_i in zip(a, b)) + sum_a_sq = sum(a_i**2 for a_i in a) + sum_b_sq = sum(b_i**2 for b_i in b) + num = n * sum_ab - sum_a * sum_b + den = sqrt(n * sum_a_sq - sum_a**2) * sqrt(n * sum_b_sq - sum_b**2) + if den == 0: + return None + return num / den +``` + +我们得到了不错的速度提升: + +```sh +Avg time per iteration: 43 μs +Speedup over baseline: 814.6x + +% Time Line Contents +===================== + def compute_corrs(qs_iter, users_who_answered_q, score_matrix, grand_totals): + 0.0 result = [] + 0.2 for qs in qs_iter: + 21.5 user_sets_for_qs = users_who_answered_q[qs, :] # numpy indexing + 18.7 answered_all = np.logical_and.reduce(user_sets_for_qs) + 19.7 answered_all = np.where(answered_all)[0] + 10.0 qs_total = score_matrix[answered_all, :][:, qs].sum(axis=1) + 5.3 user_grand_total = [grand_totals[u] for u in answered_all] + 24.1 r = corrcoef(qs_total, user_grand_total) + 0.5 result.append({"qs": qs, "r": r}) + 0.0 return result +``` + +### 优化 8 - 早期引入 Numba + +在上面的代码中,我们尚未完成数据结构的优化,但让我们来看下,如果在这个阶段引入了 [Numba](https://numba.pydata.org/),会发生什么呢。Numba 是 Python 生态中的一个库,它“将 Python 和 NumPy 代码的一个子集转换为快速的机器码”。 + +为了能够使用 Numba,我们做了两个改动: + +改动 1:将 qs_combinations 作为 numpy 数组传递,而不是 `qs_iter` + +Numba 不能很好地与 `itertools` 或者生成器配合使用,因此,我们提前将 `qs_iter` 转换为 NumPy 数组,然后才将它传给对应函数。此更改对运行时间的影响(添加 Numba 之前)如下所示。 + +```sh +Avg time per iteration: 42 μs +Speedup over baseline: 829.2x + +``` + +改动 2:结果使用数组,而不是列表 + +我们初始化一个数组,然后将结果放入其中,而不是将结果附加到列表中。此更改对运行时间的影响(添加 Numba 之前)如下所示。 + + +```sh +Avg time per iteration: 42 μs +Speedup over baseline: 833.8x + +``` + +最终,代码看起来像是这样的: + + +```py +import numba + +@numba.njit(parallel=False) +def compute_corrs(qs_combinations, users_who_answered_q, score_matrix, grand_totals): + result = np.empty(len(qs_combinations), dtype=np.float64) + for i in numba.prange(len(qs_combinations)): + qs = qs_combinations[i] + user_sets_for_qs = users_who_answered_q[qs, :] + # numba doesn't support np.logical_and.reduce + answered_all = user_sets_for_qs[0] + for j in range(1, len(user_sets_for_qs)): + answered_all *= user_sets_for_qs[j] + answered_all = np.where(answered_all)[0] + qs_total = score_matrix[answered_all, :][:, qs].sum(axis=1) + user_grand_total = grand_totals[answered_all] + result[i] = corrcoef_numba(qs_total, user_grand_total) + return result +``` + +(请注意,我们还用了 Numba 来装饰 `corrcoef`,因为 Numba 函数中的函数调用也需要经过编译。) + +#### 使用 *parallel=False* 的结果 + + +```sh +Avg time per iteration: 47 μs +Speedup over baseline: 742.2x + +``` + +#### 使用 *parallel=True* 的结果 + + + +```sh +Avg time per iteration: 8.5 μs +Speedup over baseline: 4142.0x + +``` + +我们看到,使用 `parallel=False` 的情况下, Numba 代码比之前的 Python 代码慢一点,但当我们使用了并行,从而开始使用所有的 CPU 核(运行基准测试的机器上有 10 个),这带来了很棒的速度倍增。 + +然而,我们失去了在 JIT 编译的代码上使用 [line_profiler](https://github.com/pyutils/line_profiler) 的能力(我们可能想开始查看生成的 LLVM IR/汇编)。 + + +### 优化 9 - Bitset,不使用 Numba + +我们暂时把 Numba 放在一边。原始文章使用 bitset 来快速计算回答了当前 `qs` 中问题的用户,所以,看看这是否适合我们。我们可以使用 `np.int64` 类型的 NumPy 数组以及 `np.bitwise_and.reduce` 来实现 bitset。这与我们前面使用的 `np.bool_` 数组不同,因为现在,我们使用的是字节中的各个位来表示集合中的实体。注意,对于一个给定的 bitset,我们可能需要多个字节,具体取决于我们所需的最大元素数。我们可以对 `qs` 中的每个问题的字节使用快速的 bitwise_and 来查找集合交集,从而找到回答了 `qs` 中所有问题的用户数。 + +下面是我们将用到的 `bitset` 函数: + +```py +def bitset_create(size): + """Initialise an empty bitset""" + size_in_int64 = int(np.ceil(size / 64)) + return np.zeros(size_in_int64, dtype=np.int64) + +``` + + +```py +def bitset_add(arr, pos): + """Add an element to a bitset""" + int64_idx = pos // 64 + pos_in_int64 = pos % 64 + arr[int64_idx] |= np.int64(1) << np.int64(pos_in_int64) +``` + + +```py +def bitset_to_list(arr): + """Convert a bitset back into a list of ints""" + result = [] + for idx in range(arr.shape[0]): + if arr[idx] == 0: + continue + for pos in range(64): + if (arr[idx] & (np.int64(1) << np.int64(pos))) != 0: + result.append(idx * 64 + pos) + return np.array(result) + +``` + +然后,我们可以用下述方法初始化 bitset: + +```py +users_who_answered_q = np.array( + [bitset_create(data.user.nunique()) for _ in range(data.question.nunique())] +) +for q, u in data[["question", "user"]].values: + bitset_add(users_who_answered_q[q], u) +``` + +让我们看看所得速度提升: + +```sh +Avg time per iteration: 550 μs +Speedup over baseline: 64.2x + +% Time Line Contents +===================== + def compute_corrs(qs_combinations, users_who_answered_q, score_matrix, grand_totals): + 0.0 num_qs = qs_combinations.shape[0] + 0.0 bitset_size = users_who_answered_q[0].shape[0] + 0.0 result = np.empty(qs_combinations.shape[0], dtype=np.float64) + 0.0 for i in range(num_qs): + 0.0 qs = qs_combinations[i] + 0.3 user_sets_for_qs = users_who_answered_q[qs_combinations[i]] + 0.4 answered_all = np.bitwise_and.reduce(user_sets_for_qs) + 96.7 answered_all = bitset_to_list(answered_all) + 0.6 qs_total = score_matrix[answered_all, :][:, qs].sum(axis=1) + 0.0 user_grand_total = grand_totals[answered_all] + 1.9 result[i] = corrcoef(qs_total, user_grand_total) + 0.0 return result +``` + +看起来有些倒退了,使用 `bitset_to_list` 操作花费了很多时间。 + +### 优化 10 - Numba 和 *bitset_to_list* + + +让我们将 `bitset_to_list` 转换为编译后的代码。为此,我们可以添加一个 Numba 装饰器: + +```py +@numba.njit +def bitset_to_list(arr): + result = [] + for idx in range(arr.shape[0]): + if arr[idx] == 0: + continue + for pos in range(64): + if (arr[idx] & (np.int64(1) << np.int64(pos))) != 0: + result.append(idx * 64 + pos) + return np.array(result) +``` + +让我们评估下: + +```sh +Benchmark #14: bitsets, with numba on bitset_to_list +Using 1000 iterations... + +Avg time per iteration: 19 μs +Speedup over baseline: 1801.2x + +% Time Line Contents +===================== + def compute_corrs(qs_combinations, users_who_answered_q, score_matrix, grand_totals): + 0.0 num_qs = qs_combinations.shape[0] + 0.0 bitset_size = users_who_answered_q[0].shape[0] + 0.0 result = np.empty(qs_combinations.shape[0], dtype=np.float64) + 0.3 for i in range(num_qs): + 0.6 qs = qs_combinations[i] + 8.1 user_sets_for_qs = users_who_answered_q[qs_combinations[i]] + 11.8 answered_all = np.bitwise_and.reduce(user_sets_for_qs) + 7.7 answered_all = bitset_to_list(answered_all) + 16.2 qs_total = score_matrix[answered_all, :][:, qs].sum(axis=1) + 1.1 user_grand_total = grand_totals[answered_all] + 54.1 result[i] = corrcoef(qs_total, user_grand_total) + 0.0 return result +``` + +和原始代码相比,我们获得了 1,800 倍多代码执行速度提升。回想一下优化 7,在引入 Numba 之前,代码速度提升是 814 倍。(优化 8 是 4142 倍,但那是在内循环上使用了 `parallel=True`,所以它与上面的不具有可比性。) + + +### 优化 11 - Numba 和 *corrcoef* + + +The corrcoef line is again standing out as slow above. Let’s use `corrcoef` decorated with Numba. + + + +```py +@numba.njit +def corrcoef_numba(a, b): + """same as np.corrcoef(a, b)[0, 1]""" + n = len(a) + sum_a = sum(a) + sum_b = sum(b) + sum_ab = sum(a * b) + sum_a_sq = sum(a * a) + sum_b_sq = sum(b * b) + num = n * sum_ab - sum_a * sum_b + den = math.sqrt(n * sum_a_sq - sum_a**2) * math.sqrt(n * sum_b_sq - sum_b**2) + return np.nan if den == 0 else num / den +``` + +以及基准: + + +```sh +Avg time per iteration: 11 μs +Speedup over baseline: 3218.9x + +% Time Line Contents +===================== + def compute_corrs(qs_combinations, users_who_answered_q, score_matrix, grand_totals): + 0.0 num_qs = qs_combinations.shape[0] + 0.0 bitset_size = users_who_answered_q[0].shape[0] + 0.0 result = np.empty(qs_combinations.shape[0], dtype=np.float64) + 0.7 for i in range(num_qs): + 1.5 qs = qs_combinations[i] + 15.9 user_sets_for_qs = users_who_answered_q[qs_combinations[i]] + 26.1 answered_all = np.bitwise_and.reduce(user_sets_for_qs) + 16.1 answered_all = bitset_to_list(answered_all) + 33.3 qs_total = score_matrix[answered_all, :][:, qs].sum(axis=1) + 2.0 user_grand_total = grand_totals[answered_all] + 4.5 result[i] = corrcoef_numba(qs_total, user_grand_total) + 0.0 return result +``` + +棒,另一个大的速度提升。 + +### 优化 12 - Numba 和 *bitset_and* + + +我们引入 `bitwise_and` 来替换 `np.bitwise_and.reduce`,然后对其进行 jit 编译。 + +```py +@numba.njit +def bitset_and(arrays): + result = arrays[0].copy() + for i in range(1, len(arrays)): + result &= arrays[i] + return result +``` + + +```sh +Benchmark #16: numba also on bitset_and +Using 1000 iterations... + +Avg time per iteration: 8.9 μs +Speedup over baseline: 3956.7x + +% Time Line Contents +===================== + def compute_corrs(qs_combinations, users_who_answered_q, score_matrix, grand_totals): + 0.1 num_qs = qs_combinations.shape[0] + 0.0 bitset_size = users_who_answered_q[0].shape[0] + 0.1 result = np.empty(qs_combinations.shape[0], dtype=np.float64) + 1.0 for i in range(num_qs): + 1.5 qs = qs_combinations[i] + 18.4 user_sets_for_qs = users_who_answered_q[qs_combinations[i]] + 16.1 answered_all = bitset_and(user_sets_for_qs) + 17.9 answered_all = bitset_to_list(answered_all) + 37.8 qs_total = score_matrix[answered_all, :][:, qs].sum(axis=1) + 2.4 user_grand_total = grand_totals[answered_all] + 4.8 result[i] = corrcoef_numba(qs_total, user_grand_total) + 0.0 return result +``` + +### 优化 12 - 整个函数上的 Numba + +现在,上面的代码比原始代码快得多,计算量相当均匀地分布在循环中的几行代码上。事实上,看起来最慢的那一行正在执行的是 NumPy 索引操作,这已经相当快了。那么,让我们用 Numba 编译整个函数。 + +```py +@numba.njit(parallel=False) +def compute_corrs(qs_combinations, users_who_answered_q, score_matrix, grand_totals): + result = np.empty(len(qs_combinations), dtype=np.float64) + for i in numba.prange(len(qs_combinations)): + qs = qs_combinations[i] + user_sets_for_qs = users_who_answered_q[qs, :] + answered_all = user_sets_for_qs[0] + # numba doesn't support np.logical_and.reduce + for j in range(1, len(user_sets_for_qs)): + answered_all *= user_sets_for_qs[j] + answered_all = np.where(answered_all)[0] + qs_total = score_matrix[answered_all, :][:, qs].sum(axis=1) + user_grand_total = grand_totals[answered_all] + result[i] = corrcoef_numba(qs_total, user_grand_total) + return result +``` + + +```sh +Avg time per iteration: 4.2 μs +Speedup over baseline: 8353.2x + +``` + +现在,使用 `parallel=True`: + + + +```sh +Avg time per iteration: 960 ns +Speedup over baseline: 36721.4x + +``` + +可以了,很好,我们比原始代码快了 36,000 倍。 + +### 优化 13 - Numba,inline with accumulation instead of arrays + +我们接下来要干什么呢?...好吧,在上面的代码中仍然有相当多的将值放入数组中,然后传递它们的操作。由于我们正在努力优化此代码,因此我们可以查看 corrcoef 的计算方式,染灰会发现我们不需要构建数组 `answered_all` 和 `user_grand_total`,相反,我们可以在循环时累积值。 + +这里是代码(我们还启用了一些编译器优化,例如禁用数组的 `boundschecking` 和启用 `fastmath`)。 + + +```py +@numba.njit(boundscheck=False, fastmath=True, parallel=False, nogil=True) +def compute_corrs(qs_combinations, users_who_answered_q, score_matrix, grand_totals): + num_qs = qs_combinations.shape[0] + bitset_size = users_who_answered_q[0].shape[0] + corrs = np.empty(qs_combinations.shape[0], dtype=np.float64) + for i in numba.prange(num_qs): + # bitset will contain users who answered all questions in qs_array[i] + bitset = users_who_answered_q[qs_combinations[i, 0]].copy() + for q in qs_combinations[i, 1:]: + bitset &= users_who_answered_q[q] + # retrieve stats for the users to compute correlation + n = 0.0 + sum_a = 0.0 + sum_b = 0.0 + sum_ab = 0.0 + sum_a_sq = 0.0 + sum_b_sq = 0.0 + for idx in range(bitset_size): + if bitset[idx] != 0: + for pos in range(64): + if (bitset[idx] & (np.int64(1) << np.int64(pos))) != 0: + user_idx = idx * 64 + pos + score_for_qs = 0.0 + for q in qs_combinations[i]: + score_for_qs += score_matrix[user_idx, q] + score_for_user = grand_totals[user_idx] + n += 1.0 + sum_a += score_for_qs + sum_b += score_for_user + sum_ab += score_for_qs * score_for_user + sum_a_sq += score_for_qs * score_for_qs + sum_b_sq += score_for_user * score_for_user + num = n * sum_ab - sum_a * sum_b + den = np.sqrt(n * sum_a_sq - sum_a**2) * np.sqrt(n * sum_b_sq - sum_b**2) + corrs[i] = np.nan if den == 0 else num / den + return corrs +``` + +我们从使用 `parallel=False` 开始。 + +```sh +Avg time per iteration: 1.7 μs +Speedup over baseline: 20850.5x + +``` + +这应该与优化 12 中设置 `parallel=False` 的情况(测量结果为 8353 倍提升)进行比较。 + +现在,使用 `parallel=True`。 + +```sh +Avg time per iteration: 210 ns +Speedup over baseline: 170476.3x + +``` + +很好,我们已经将 Python 基线的速度提高了 170,000 倍。 + + +### 总结 + +得益于 Numba 和 NumPy,我们已经能够获得使优化的 Rust 代码变得更快的大部分功能,特别是位集、SIMD 和循环级并行性。首先,我们通过 JIT 编译了一些辅助函数,使原始 Python 代码变得相当快,但最后,我们对整个代码进行了 JIT 编译,并为此优化了代码。我们采取了试验和改进的方法,使用分析将我们的工作重点放在最慢的代码行上。我们展示了可以使用 Numba 将 JIT 编译的代码逐渐混合到我们的 Python 代码中。我们可以立即将此代码放入现有的 Python 代码库中。然而,我们没有达到像优化后的 Rust 代码那样 180,000 倍的速度提升,我们推出了自己的相关性和位集实现,而 Rust 代码能够使用一些库来实现这些功能,同时保持其性能。 + +这是一个有趣的练习,希望它展示了 Python 生态系统中的一些有用的工具。 + +我会特别推荐其中某种方法吗?不,要使用哪种方法取决于具体情况。 + + +#### 笔记 + +完整的代码在[这里(GitHub)](https://github.com/sradc/corrset-benchmark-fork/tree/main/python_optimization)。 \ No newline at end of file diff --git "a/Others/\350\247\243\351\207\212\346\211\207\345\207\272\346\250\241\345\274\217\357\274\210Fanout Pattern\357\274\211.md" "b/Others/\350\247\243\351\207\212\346\211\207\345\207\272\346\250\241\345\274\217\357\274\210Fanout Pattern\357\274\211.md" new file mode 100644 index 0000000..35ed808 --- /dev/null +++ "b/Others/\350\247\243\351\207\212\346\211\207\345\207\272\346\250\241\345\274\217\357\274\210Fanout Pattern\357\274\211.md" @@ -0,0 +1,177 @@ +原文:[The Fanout Pattern Explained](https://www.better-simple.com/django/2023/12/06/fanout-pattern-explained/) + +--- + +# 解释扇出模式(Fanout Pattern) + +_2023 年 12 月 06 日_ + +在我在 [AspirEDU](https://www.aspiredu.com) 的工作中,我们每天都使用 Celery 来捕获教育信息。我们已经采用了几种不同的策略来设计 Celery 的任务签名[1](#fn:1)。其中最强大的策略是**扇出模式(Fanout Pattern)**。 + + +### 扇出模式指的是用可变数量的其他任务替换自身的单个任务。 + +来一起看看一些代码。如果我们有如下的任务签名: + + +```py +task1.si() | task2.si() | task3.si() +``` + +每项任务必须在下一项任务开始之前完成。但是,假设在 `task2` 中,我们正在获取一些集合,并且需要为集合中的每个项目运行另一个任务。扇出模式将替换 `task2`为 `item1, item2, ..., itemN`,其中 N 是集合中的项目数。 + +下面解释了同个意思,但是用代码的方式进行了解释: + +```py +# We schedule this: +( + task1.si() + | task2.si() + | task3.si() +).apply_async() +# But this is what runs: +( + task1.si() + | task2.si() + | group([item1.si(), item2.si(), itemN.si()]) + | task3.si() +).apply_async() +``` + +记住,您不需要用一组其他任务替换这个任务。在 Celery 中,您可以将当前正在运行的任务替换为任何其他任务签名,例如单个任务或复杂的任务签名。 + +下面深入探讨了一个示例及这个模式,但您可能可以摆脱上面的示例并[阅读关于 `Task.replace` 的文档](https://docs.celeryq.dev/en/stable/reference/celery.app.task.html#celery.app.task.Task.replace)。 + + +## 现实的 Taco Bell 示例问题 + +一个更现实的例子是,您的任务是捕获每个 Taco Bell [2](#fn:2) Franchise 的所有菜单选项,然后发送一封包含最不常列出的项目[3](#fn:3)的电子邮件。您需要使用其中的数据的 API 端点是: + +* `fetch_franchises -> list[Franchise]` +* `fetch_menu(franchise_id: int) -> Menu` + + +假设我们创建一个 Celery 任务来负责每个 API 端点。 + +```py +from celery import shared_task + +@shared_task +def capture_franchises(): + for franchise in fetch_franchises(): + # Do something + + +@shared_task +def capture_menu_for_franchise(franchise_id: int): + for menu_item in fetch_menu(franchise_id).menu_items: + # Do something +``` + +现在,我们发送报告的任务是: + +```py +from celery import shared_task +from django.core.mail import send_mail +from .models import MenuItem # Our imaginary django model + +@shared_task +def send_report(): + least_listed_menu_items = MenuItem.objects.least_listed().values_list('name', flat=True) + send_mail( + subject="Least listed items report", + message=f"{', '.join(least_listed_menu_items)}", + recipient_list=["menu_design@taco-bell.better-simple.com"], + from_email="fanout_pattern@better-simple", + ) +``` + +挑战在于,我们如何创建一个 Celery 任务签名来运行 `capture_franchises`,然后为找到的每个 franchise 运行 `capture_menu_for_franchise`,接着在所有这些任务完成后,调用运行 `send_report` 任务。 + +一种解决方案就是扇出模式。 + +## 实践中的扇出模式 + +扇出模式的关键是能够[用一个任务替换另一个任务](https://docs.celeryq.dev/en/stable/reference/celery.app.task.html#celery.app.task.Task.replace)签名。 + +在 Celery 中,要替换任务,您必须通过 `@shared_task(bind=True)` 或 `@app.task(bind=True)`[4](#fn:4) 创建[绑定任务](https://docs.celeryq.dev/en/stable/userguide/tasks.html#bound-tasks)。这使您可以通过任务参数 `self` 访问[任务请求](https://docs.celeryq.dev/en/stable/userguide/tasks.html#task-request-info)。然后就是调用 `self` 的 [`replace`](https://docs.celeryq.dev/en/stable/reference/celery.app.task.html#celery.app.task.Task.replace) 方法了。 + +有很多链接和文档。所以这里的代码应该能够强调我的观点: + +```py +from celery import group +from .models import Franchise # Our imaginary django model + +@shared_task(bind=True) +def capture_franchises(self): + for franchise in fetch_franchises(): + # Do something + + # We now have fetched all franchises, let's replace this + # task with another task signature + + self.replace( + group([ + capture_menu_for_franchise.si(franchise_id=franchise.id) + for franchise in Franchise.objects.all() + ]) + ) +``` + +您可以看到,我们正在通过 `self.replace()` 这行代码,使用一组 `capture_menu_for_franchise` 任务来替换任务 `capture_franchises`。 + +现在我们需要将报告任务链接到上面的代码中。 + +```py +def run_least_listed_report(): + signature = capture_franchises.si() | send_report.si() + signature.apply_async() +``` + +## 关于任务设计,再多说一句 + +如果您像我一样,以上内容并不适合您。这个 `signature` 定义(`capture_franchises.si() | send_report.si()`)对读者来说并无意义。franchises 被捕获了,然后报告就发出来了?如果菜单也被捕获,这是否意味着还有其他数据也在 `capture_franchises` 中被捕获了? + +相反,我认为更合适的解决方案是: + +```py +@shared_task +def capture_franchises(): + for franchise in fetch_franchises(): + # Do something + + +@shared_task(bind=True) +def capture_franchises_menu_fanout(self): + franchise_ids = list(Franchise.objects.all().values_list("id", flat=True)) + if franchise_ids: + # Celery doesn't handle group([]) with an empty collection well + # so don't replace if there are no franchises stored + self.replace( + group([ + capture_menu_for_franchise.si(franchise_id=franchise_id) + for franchise_id in franchise_ids + ]) + ) +``` + +新的签名将是: + +```py +capture_franchises.si() | capture_franchises_menu_fanout.si() | send_report.si() + +``` + +对于其他类似工作流程来说,这更具描述性并且更容易扩展或复制。 + +## 回顾 + +扇出模式是在 Celery 任务签名中实现动态工作流程的好方法。您可以使用它来减小签名的大小,并根据外部数据以编程方式选择下一个任务。 + +我希望您觉得这篇文章有用。如果您有疑问,请随时与我联系。您可以在 [Fediverse](https://fosstodon.org/@CodenameTim)、[Django Discord server](https://discord.gg/xcRH6mN4fa) 或通过[电子邮件](mailto:schillingt@better-simple.com)找到我。 + + +1. 一个 Celery 任务签名意味着一个或多个链接在一起的 Celery 任务。[↩](#fnref:1) +2. 芝士戈迪塔脆饼和鸡肉玉米饼。这是您不知道的问题的答案。 [↩](#fnref:2) +3. 我们使用最不常列出的项目,因为它要求您无论如何都会搜索每个 franchise。[↩](#fnref:3) +4. 我使用 [`shared_task` 是因为它被推荐用于 Django](https://docs.celeryq.dev/en/stable/userguide/tasks.html#how-do-i-import-the-task-decorator),但如果你喜欢,你可以使用 `app.task` 。 [↩](#fnref:4) \ No newline at end of file diff --git "a/Python Common/Python \347\211\210\346\234\254\351\227\264\347\232\204\344\270\273\350\246\201\345\217\230\345\212\250\347\232\204\346\200\273\347\273\223.md" "b/Python Common/Python \347\211\210\346\234\254\351\227\264\347\232\204\344\270\273\350\246\201\345\217\230\345\212\250\347\232\204\346\200\273\347\273\223.md" new file mode 100644 index 0000000..d21bb1c --- /dev/null +++ "b/Python Common/Python \347\211\210\346\234\254\351\227\264\347\232\204\344\270\273\350\246\201\345\217\230\345\212\250\347\232\204\346\200\273\347\273\223.md" @@ -0,0 +1,487 @@ +原文:[Python 版本间的主要变动的总结](https://www.nicholashairs.com/posts/major-changes-between-python-versions/) + +--- + + +# Python 版本间的主要变动的总结 + +_Feb 2, 2024_ + + + + + +![Summary of Major Changes Between Python Versions](https://images.unsplash.com/photo-1538439907460-1596cafd4eff?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wxMTc3M3wwfDF8c2VhcmNofDR8fHB5dGhvbnxlbnwwfHx8fDE3MDY4NjA1MDl8MA&ixlib=rb-4.0.3&q=80&w=2000) +摄影:[David Clode](https://unsplash.com/@davidclode?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit) / [Unsplash](https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit) + + + +This post is designed to be a quick reference for the major changes introduced with each new version of Python. This can help with taking advantages of using new features as you upgrade your code base, or ensuring that you have the correct guards for compatibility with older versions. + +There are two sections to this post: the first covers the actual changes, the second useful tools, links, and utilities that can aid with upgrading code bases. + +# 版本 + +In this section I've documented the major changes to the Python syntax and standard library. Except for the `typing` module I've mostly excluded changes to modules. I have **not** included any changes to the C-API, byte-code, or other low level parts. + +For each section the end-of-life date (EOL) refers to the date at which the Python Software Foundation will not longer provide security patches for a particular version. + +## [Python 3.7 及更早版本](https://docs.python.org/3/whatsnew/index.html) + +This section has been combined as all these versions are already EOL at the time of writing, but if you've been programming in Python for a while you may have forgotten about when these features were introduced. + +* async and await (3.5+) +* matrix operator: `a @ b` (3.5+) +* type hints (3.5+) +* [Formatted String Literals](https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals) (aka f-strings) `f"{something}"` (3.6+) +* underscore in numeric literals `1_000_000` (3.6+) +* dictionaries are guaranteed insertion ordered (3.7+) +* `contextvars` (3.7+) +* `dataclasses` (3.7+) +* `importlib.resources` (3.7+) + +## [Python 3.8](https://docs.python.org/3/whatsnew/3.8.html) (EOL Oct 2024) + +### 赋值表达式 + +也称为海象运算符(Walrus operator) + +```py +if (thing := get_thing()) is not None: + do_something(thing) +else: + raise Exception(f"Something is wrong with {thing}") +``` + +### Positional only parameters + + +```py +def foo(a, b, /, c, d, *, e, f): + # a, b: positional only + # c, d: positional or keyword + # e, f: keyword only +``` + +### Self documenting f-strings + + +```py +# Before +f"user={user}" + +# Now +f"{user=}" +``` +### Importlib Metadata + + +```py +import importlib.metadata +importlib.metadata.version("some-library") +# "2.3.4" +importlib.metadata.requires("some-library") +# ["thing==1.2.4", "other>=5"] +importlib.metadata.files("some-library") +# [...] +``` +### Typing: `TypedDict`, `Literal`, `Final`, `Protocol` + +* `TypedDict` - [PEP 589](https://peps.python.org/pep-0589/) +* `Literal` - [PEP 586](https://peps.python.org/pep-0586/) +* `Final` - [PEP 591](https://peps.python.org/pep-0591/) +* `Protocol` - [PEP 544](https://peps.python.org/pep-0544/) + +## [Python 3.9](https://docs.python.org/3/whatsnew/3.9.html) (EOL Oct 2025) + +### Typing: Builtin Generics + +Can now use `dict[...]`, `list[...]`, `set[...]` etc instead of using `typing.Dict, List, Set`. + +### Remove Prefix/Suffix + +Strings and similar types can now use `removeprefix` and `removesuffix` to more safely remove things from the start or end. This is safer than string slicing methods which rely on correctly counting the length of the prefix (and remembering to change the slice if the prefix changes). + + +``` +if header.startswith("X-Forwarded-"): + section = header.removeprefix("X-Forwarded-") +``` +### Dict Union Operator ([PEP 584](https://peps.python.org/pep-0584/)) + + +``` +combined_dict = dict_one | dict_two +updated_dict |= dict_three +``` +### Annotations ([PEP 593](https://peps.python.org/pep-0593/)) + + +``` +my_int: Annotated[int, SomeRange(0, 255)] = 0 +``` +### Zoneinfo ([PEP 615](https://peps.python.org/pep-0615/)) + +IANA Time Zone Database is now part of standard library + + +``` +import zoneinfo +some_zone = zoneinfo.ZoneInfo("Europe/Berlin") +``` +## [Python 3.10](https://docs.python.org/3/whatsnew/3.10.html) (EOL Oct 2026) + +### Structural Pattern Matching ([PEP 634](https://peps.python.org/pep-0634/), [PEP 635](https://peps.python.org/pep-0635/), [PEP 636](https://peps.python.org/pep-0636/)) + +[See change log for more examples.](https://docs.python.org/3/whatsnew/3.10.html#pep-634-structural-pattern-matching) + + +``` +match command.split(): + case ["quit"]: + print("Goodbye!") + quit_game() + case ["look"]: + current_room.describe() + case ["get", obj]: + character.get(obj, current_room) + case ["go", direction]: + current_room = current_room.neighbor(direction) + case [action]: + ... # interpret single-verb action + case [action, obj]: + ... # interpret action, obj + case _: + ... # anything that didn't match +``` +### Typing: Union using pipe + + +``` +# Before +from typing import Optional, Union +thing: Optional[Union[str, list[str]]] = None + +# Now +thing: str | list[str] | None = None +``` +### Typing: `ParamSpec` ([PEP 612](https://peps.python.org/pep-0612/)) + +Allows for much better passing of typing information when working with `Callable` and other similar types. + + +```py +from typing import Awaitable, Callable, ParamSpec, TypeVar + +P = ParamSpec("P") +R = TypeVar("R") + +def add_logging(f: Callable[P, R]) -> Callable[P, Awaitable[R]]: + async def inner(*args: P.args, **kwargs: P.kwargs) -> R: + await log_to_database() + return f(*args, **kwargs) + return inner + +@add_logging +def takes_int_str(x: int, y: str) -> int: + return x + 7 + +await takes_int_str(1, "A") # Accepted +await takes_int_str("B", 2) # Correctly rejected by the type checker +``` +### Typing: `TypeAlias` ([PEP 613](https://peps.python.org/pep-0613/)) + + +``` +StrCache: TypeAlias = 'Cache[str]' # a type alias +LOG_PREFIX = 'LOG[DEBUG]' # a module constant +``` +### Typing: `TypeGuard` ([PEP 647](https://peps.python.org/pep-0647/)) + + +```py +_T = TypeVar("_T") + +def is_two_element_tuple(val: Tuple[_T, ...]) -> TypeGuard[Tuple[_T, _T]]: + return len(val) == 2 + +def func(names: Tuple[str, ...]): + if is_two_element_tuple(names): + reveal_type(names) # Tuple[str, str] + else: + reveal_type(names) # Tuple[str, ...] +``` +### Parenthesized Context Managers ([PEP 617](https://peps.python.org/pep-0617/)) + + +```py +with (CtxManager() as example): + ... + +with ( + CtxManager1(), CtxManager2() +): + ... + +with (CtxManager1() as example, CtxManager2()): + ... + +with (CtxManager1(), CtxManager2() as example): + ... + +with ( + CtxManager1() as example1, + CtxManager2() as example2, +): + ... +``` + +### Dataclasses: `slots`, `kw_only` + +[Dataclass decorator](https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass) now supports following: + +* `kw_only=True` all parameters in `__init__` will be marked keyword only. +* `slots=True` the generatred dataclass will use `__slots__` for storing data. + +## [Python 3.11](https://docs.python.org/3/whatsnew/3.11.html) (EOL Oct 2027) + +### Tomllib + +`[tomllib](https://docs.python.org/3/library/tomllib.html#module-tomllib)` - Standard library TOML parser + +### Exception Groups ([PEP 654](https://peps.python.org/pep-0654/)) + + +> [**PEP 654**](https://peps.python.org/pep-0654/) introduces language features that enable a program to raise and handle multiple unrelated exceptions simultaneously. The builtin types [`ExceptionGroup`](https://docs.python.org/3/library/exceptions.html#ExceptionGroup) and [`BaseExceptionGroup`](https://docs.python.org/3/library/exceptions.html#BaseExceptionGroup) make it possible to group exceptions and raise them together, and the new [`except*`](https://docs.python.org/3/reference/compound_stmts.html#except-star) syntax generalizes [`except`](https://docs.python.org/3/reference/compound_stmts.html#except) to match subgroups of exception groups. + +### Enriching Exceptions with notes ([PEP 678](https://peps.python.org/pep-0678/)) + + +> The [`add_note()`](https://docs.python.org/3/library/exceptions.html#BaseException.add_note) method is added to [`BaseException`](https://docs.python.org/3/library/exceptions.html#BaseException). It can be used to enrich exceptions with context information that is not available at the time when the exception is raised. The added notes appear in the default traceback. + + +``` +try: + do_something() +except BaseException as e: + e.add_note("this happened during do_something") + raise +``` +### Typing: `Self` ([PEP 673](https://peps.python.org/pep-0673/)) + + +``` +class MyClass: + @classmethod + def from_hex(cls, s: str) -> Self: # Self means instance of cls + return cls(int(s, 16)) + + def frobble(self, x: int) -> Self: # Self means this instance + self.y >> x + return self +``` +### Typing: LiteralString ([PEP 675](https://peps.python.org/pep-0675/)) + + +> The new [`LiteralString`](https://docs.python.org/3/library/typing.html#typing.LiteralString) annotation may be used to indicate that a function parameter can be of any literal string type. This allows a function to accept arbitrary literal string types, as well as strings created from other literal strings. Type checkers can then enforce that sensitive functions, such as those that execute SQL statements or shell commands, are called only with static arguments, providing protection against injection attacks. + +### Typing: Marking `TypedDict` entries as [not] required ([PEP 655](https://peps.python.org/pep-0655/)) + + +``` +# default is required +class Movie(TypedDict): + title: str + year: NotRequired[int] + +# default is not-required +class Movie(TypedDict, total=False): + title: Required[str] + year: int +``` +### Typing: Variadic Generics via `TypeVarTuple` ([PEP 646](https://peps.python.org/pep-0646/)) + + +> [**PEP 484**](https://peps.python.org/pep-0484/) previously introduced [`TypeVar`](https://docs.python.org/3/library/typing.html#typing.TypeVar), enabling creation of generics parameterised with a single type. [**PEP 646**](https://peps.python.org/pep-0646/) adds [`TypeVarTuple`](https://docs.python.org/3/library/typing.html#typing.TypeVarTuple), enabling parameterisation with an *arbitrary* number of types. In other words, a [`TypeVarTuple`](https://docs.python.org/3/library/typing.html#typing.TypeVarTuple) is a *variadic* type variable, enabling *variadic* generics. + + +> This enables a wide variety of use cases. In particular, it allows the type of array-like structures in numerical computing libraries such as NumPy and TensorFlow to be parameterised with the array *shape*. Static type checkers will now be able to catch shape-related bugs in code that uses these libraries. + +### Typing: `@dataclass_transform` ([PEP 681](https://peps.python.org/pep-0681/)) + + +> [`dataclass_transform`](https://docs.python.org/3/library/typing.html#typing.dataclass_transform) may be used to decorate a class, metaclass, or a function that is itself a decorator. The presence of `@dataclass_transform()` tells a static type checker that the decorated object performs runtime “magic” that transforms a class, giving it [`dataclass`](https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass)-like behaviors. + + +``` +# The create_model decorator is defined by a library. +@typing.dataclass_transform() +def create_model(cls: Type[T]) -> Type[T]: + cls.__init__ = ... + cls.__eq__ = ... + cls.__ne__ = ... + return cls + +# The create_model decorator can now be used to create new model classes: +@create_model +class CustomerModel: + id: int + name: str +``` +### Star unpacking expressions allowed in `for` statements: + +This is officially supported syntax + + +``` +for x in *a, *b: + print(x) +``` +## [Python 3.12](https://docs.python.org/3/whatsnew/3.12.html) (EOL Oct 2028) + +### Typing: Type Parameter Syntax ([PEP 695](https://peps.python.org/pep-0695/)) + +Compact annotion of generic classes and functions + + +``` +def max[T](args: Iterable[T]) -> T: + ... + +class list[T]: + def __getitem__(self, index: int, /) -> T: + ... + + def append(self, element: T) -> None: + ... +``` +Ability to declare type aliases using `type` statement (generates `TypeAliasType`) + + +``` +type Point = tuple[float, float] + +# Type aliases can also be generic +type Point[T] = tuple[T, T] +``` +### F-string changes ([PEP 701](https://peps.python.org/pep-0701/)) + + +> Expression components inside f-strings can now be any valid Python expression, including strings reusing the same quote as the containing f-string, multi-line expressions, comments, backslashes, and unicode escape sequences. + +Can re-use quotes (including nesting f-string statements + + +``` +## Can re-use quotes +f"This is the playlist: {", ".join(songs)}" + +f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}" # '2' + +## Multiline f-string with comments +f"This is the playlist: {", ".join([ + 'Take me back to Eden', # My, my, those eyes like fire + 'Alkaline', # Not acid nor alkaline + 'Ascensionism' # Take to the broken skies at last +])}" + +## Backslashes / Unicode +f"This is the playlist: {"\n".join(songs)}" + +f"This is the playlist: {"\N{BLACK HEART SUIT}".join(songs)}" +``` +### Buffer protocol ([PEP 688](https://peps.python.org/pep-0688/)) + + +> [**PEP 688**](https://peps.python.org/pep-0688/) introduces a way to use the [buffer protocol](https://docs.python.org/3/c-api/buffer.html#bufferobjects) from Python code. Classes that implement the [`__buffer__()`](https://docs.python.org/3/reference/datamodel.html#object.__buffer__) method are now usable as buffer types. + + +> The new [`collections.abc.Buffer`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Buffer) ABC provides a standard way to represent buffer objects, for example in type annotations. The new [`inspect.BufferFlags`](https://docs.python.org/3/library/inspect.html#inspect.BufferFlags) enum represents the flags that can be used to customize buffer creation. + +### Typing: `Unpack` for `**kwargs` typing ([PEP 692](https://peps.python.org/pep-0692/)) + + +``` +from typing import TypedDict, Unpack + +class Movie(TypedDict): + name: str + year: int + +def foo(**kwargs: Unpack[Movie]): + ... +``` +### Typing: `override` decorator ([PEP 698](https://peps.python.org/pep-0698/)) + +Ensure's that the method being overridden by a child class actually exists in a parent class. + + +``` +from typing import override + +class Base: + def get_color(self) -> str: + return "blue" + +class GoodChild(Base): + @override # ok: overrides Base.get_color + def get_color(self) -> str: + return "yellow" + +class BadChild(Base): + @override # type checker error: does not override Base.get_color + def get_colour(self) -> str: + return "red" +``` +# Useful Things + +## Postponed Annotations ([PEP 563](https://peps.python.org/pep-0563/)) + +In newer versions of Python, typing annotations are stored as strings when they are initially parsed. This helps with preventing circular imports, needing to quote references before they are defined, and many other issues. All versions of Python from 3.7 support +`from __future__ import annotations` +which allows the interpreter to parse using this new format. + +Note: PEP 563 has been superseded by [PEP 649](https://peps.python.org/pep-0649/) which will be implemented in Python 3.13. + +## Typing Extensions + +This library back-ports typing features so that they are available to type checkers inspecting older code bases. + + +``` +import sys + +if sys.version_info < (3, 10): + from typing_extensions import TypeAlias +else: + from typing import TypeAlias +``` +[GitHub - python/typing\_extensions: Backported and experimental type hints for PythonBackported and experimental type hints for Python. Contribute to python/typing\_extensions development by creating an account on GitHub.![](https://github.com/fluidicon.png)GitHubpython![](https://opengraph.githubassets.com/0f8d9da934deba8a9b780f965eb7a8a75fadb7efb3355a652ddc987e5a24aafe/python/typing_extensions)](https://github.com/python/typing_extensions)## Python Support Schedule + +To keep track of which versions of Python are support I use the following website: + +[PythonCheck end-of-life, release policy and support schedule for Python.![](https://endoflife.date/assets/apple-touch-icon.png)endoflife.date![](https://endoflife.date/assets/logo-512x512.png)](https://endoflife.date/python)## Ruff + +This is a linter and code formatter written in Rust. It's becoming very popular as it can replace a number of existing tools and is very fast. It also includes the ability to auto-fix errors. + +Thus you can combine ruff with it's pyupgrade compatible linter (`UP`) and then use +`ruff check --fix` to auto upgrade the code base. + +When using `pyproject.toml` ruff will respect the versions specified by +`project.requires-python`. + +[GitHub - astral-sh/ruff: An extremely fast Python linter and code formatter, written in Rust.An extremely fast Python linter and code formatter, written in Rust. - GitHub - astral-sh/ruff: An extremely fast Python linter and code formatter, written in Rust.![](https://github.com/fluidicon.png)GitHubastral-sh![](https://opengraph.githubassets.com/92aab8b067f8bd03006eff26db63239960e7e38687c2d3d8a5b28ab8b98131a1/astral-sh/ruff)](https://github.com/astral-sh/ruff)## Pyupgrade + +This tool can be used to automatically upgrade your code base. + +[GitHub - asottile/pyupgrade: A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language.A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language. - GitHub - asottile/pyupgrade: A tool (and pre-commit hook) to automatically upgrade syntax for newe...![](https://github.com/fluidicon.png)GitHubasottile![](https://opengraph.githubassets.com/b6729be5dce8f0af4aa7a1f5b5505c8735e2506a927d10c8a55d4f7bd6ba4ceb/asottile/pyupgrade)](https://github.com/asottile/pyupgrade)## Black + +Black is a popular code formatter. + +When using `pyproject.toml` black will respect the versions specified by +`project.requires-python`. + +[GitHub - psf/black: The uncompromising Python code formatterThe uncompromising Python code formatter. Contribute to psf/black development by creating an account on GitHub.![](https://github.com/fluidicon.png)GitHubpsf![](https://repository-images.githubusercontent.com/125266328/48aef880-6cce-11e9-9e3c-3ca0dd3ac138)](https://github.com/psf/black) + + + diff --git "a/Python Common/Python \351\231\267\351\230\261\357\274\232Join vs Concat.md" "b/Python Common/Python \351\231\267\351\230\261\357\274\232Join vs Concat.md" new file mode 100644 index 0000000..9208bd6 --- /dev/null +++ "b/Python Common/Python \351\231\267\351\230\261\357\274\232Join vs Concat.md" @@ -0,0 +1,77 @@ +原文:[Python Gotcha: Join vs Concat](https://andrewwegner.com/python-gotcha-join-vs-concat.html) + +--- + +## 问题[¶](#the-problem "Permanent link") + +这是一个有点人为的示例,用来演示问题所在。我需要创建一个包含 100,000 个 `word` 的字符串。生成该字符串的最快方法是什么呢?我可以使用字符串连接(只是用 `+` 将字符串相互连接)。我还可以在包含 100,000 个元素的列表上使用 [`join`](https://docs.python.org/3/library/stdtypes.html#str.join)。 + +为此,我的示例代码如下 + +```py +def concat_string(word: str, iterations: int = 100000) -> str: + final_string = "" + for i in range(iterations): + final_string += word + return final_string + +def join_string(word: str, iterations: int = 100000) -> str: + final_string = [] + for i in range(iterations): + final_string.append(word) + return "".join(final_string) +``` + +## 结果[¶](#results "Permanent link") + +在 `concat_string` 中,我迭代了 100,000 个元素,每次迭代都将 我的 `word` 添加到字符串末尾。在 `join_string` 中,我在每次迭代时将我的 `word` 附加到列表中,然后在末尾将列表连接成字符串。 + +通过内置分析器 (`cProfile`) 运行每个函数会显示这两个函数的执行情况。 + + +```sh +>>> cProfile.run('concat_string("word ")') + + 4 function calls in 1.026 seconds + +Ordered by: standard name + +ncalls tottime percall cumtime percall filename:lineno(function) + 1 0.000 0.000 1.026 1.026 :1() + 1 1.026 1.026 1.026 1.026 test.py:9(concat_string) + 1 0.000 0.000 1.026 1.026 {built-in method builtins.exec} + 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} + +>>> cProfile.run('join_string("word ")') + + 100005 function calls in 0.013 seconds + +Ordered by: standard name + +ncalls tottime percall cumtime percall filename:lineno(function) + 1 0.000 0.000 0.013 0.013 :1() + 1 0.009 0.009 0.013 0.013 test.py:16(join_string) + 1 0.000 0.000 0.013 0.013 {built-in method builtins.exec} +100000 0.004 0.000 0.004 0.000 {method 'append' of 'list' objects} + 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} + 1 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects} +``` + +## 这里发生了什么?[¶](#whats-happening-here "Permanent link") + + +`join` 比连接方法快了 75 倍以上。 + +为什么呢? + +字符串是 Python 中不可变的对象。我在上一篇[关于默认参数的陷阱文章](https://andrewwegner.com/python-gotcha-optional-default-arguments.html)中对其进行了讨论。这种不变性意味着不能更改字符串。`concat_string` 看起来好像每次 `+` 操作都会更改字符串,但实际上,Python 必须在循环的每次迭代中创建一个新的字符串对象。这意味着有 99,999 个临时字符串值 - 几乎所有这些值都在连接操作期间的下一次迭代中被立即创建和丢弃。 + +另一方面,`join_string` 将 100,000 个字符串对象附加到列表中。但在此过程中仅创建了一个列表。最终的 `join` 仅对所有 100,000 个字符串进行*一次*串联。 + + + +## 这意味着什么?[¶](#what-are-the-implications-of-this "Permanent link") + +虽然这是一个展示问题的人为示例,对字符串不变性的实际性能影响可能并不明显。Python 中还有其他常用的创建新字符串的地方。例如`f-strings`,`%s` 格式说明符和 `.format()`。它们中每一个都会创建一个全新的字符串。 + +这并不意味着您应该避免使用这些,因为只有在将*大量*字符串附加在一起的情况下,性能影响才会真正明显。但是,如果循环中有字符串格式化行,那么它就是一个需要重点关注的性能改进之处。 \ No newline at end of file diff --git "a/Python Common/Python \351\231\267\351\230\261\357\274\232\346\257\224\350\276\203.md" "b/Python Common/Python \351\231\267\351\230\261\357\274\232\346\257\224\350\276\203.md" new file mode 100644 index 0000000..7556eb2 --- /dev/null +++ "b/Python Common/Python \351\231\267\351\230\261\357\274\232\346\257\224\350\276\203.md" @@ -0,0 +1,198 @@ +原文:[Python Gotcha: Comparisons](https://andrewwegner.com/python-gotcha-comparisons.html) + +--- + +# Python 陷阱:比较 + + +## 浮点数等价性比较[¶](#float-equality-comparisons "Permanent link") + +与其他所有编程语言一样,Python 也无法准确表示浮点数。我确信许多计算机科学专业的学生已经花费了很多时间来学习[如何表示浮点](https://www.doc.ic.ac.uk/~eedwards/compsys/float/)。那堂课我记得很清楚。 + +无论如何,让我们讨论一下Python 中比较 `float` 值的问题以及如何处理它。 + +```py +>>> 0.1 + 0.2 == 0.3 +False + +``` + +你、我,以及任何读过几年小学的人都可以看出,这*应该是* `True`。 + +那这里发生了什么呢?我们通过分解这个比较的组成部分就可以看出问题所在。 + +```py +>>> 0.3 +0.3 +>>> 0.1 + 0.2 +0.30000000000000004 + +``` +现在我们已经看到了导致问题的浮点表示形式。 + +那么,我们该如何处理这个问题呢? + + +### Decimal[¶](#decimal "Permanent link") + +有几种选择,它们都有各自的缺点。让我们从 [`Decimal`](https://docs.python.org/3/library/decimal.html) 开始。 + +> +> The decimal module provides support for fast correctly rounded decimal floating point arithmetic. (decimal 模块提供对快速正确舍入的十进制浮点运算的支持。) +> + +这听起来不错,但这里的一个重要问题是,它如何处理数字与字符串。 + + +```py +>>> from decimal import Decimal +>>> Decimal(0.1) +Decimal('0.1000000000000000055511151231257827021181583404541015625') +>>> Decimal('0.1') +Decimal('0.1') + +``` +这意味着,为了完成上面的比较,我们需要将每个数字包装在一个字符串中。 + +```py +>>> Decimal('0.1') + Decimal('0.2') == Decimal('0.3') +True + +``` + +很烦,但确实能用。 + +### isclose[¶](#isclose "Permanent link") + +Python 3.5 实现了 [PEP 485](https://peps.python.org/pep-0485/) 来测试近似相等。这是在 [`isclose`](https://docs.python.org/3/library/math.html#math.isclose) 函数中完成的。 + + +```py +>>> import math +>>> math.isclose(0.1+0.2,0.3) +True + +``` + +这比把所有东西都用字符串包裹起来更干净。但是,它也比简单的 `==` 语句更冗长。它让您的代码不太干净,但确实提供了准确的比较。 + +## is vs. ==[¶](#is-vs "Permanent link") + +我经常看到的另一个被误用的比较是,开发人员用了 `is`但他们其实是想表达 `==`. 简而言之,`is` **仅**当您检查两个引用是否引用同一对象时才应使用。`==` 用于通过调用底层方法 `__eq__` 来比较值。 + +让我们看看实际效果: + +```py +>>> a = [1, 2, 3] +>>> b = a +>>> c = [1, 2, 3] +>>> d = [3, 2, 1] +>>> a == b +True +>>> a == c +True +>>> a == d +False + +``` +到目前为止,没有什么异常。`a` 具有和 `b` 与 `c` 相同的值,并且与 `d` 具有不同的值。现在让我们使用 `is` + +```py +>>> a is b +True +>>> b is a +True +>>> a is c +False +>>> a is d +False +>>> b is c +False + +``` + +这里,唯一为 `True` 的语句是 `a` 和 `b` 之间的比较。这是因为 `b` 是用 `b = a` 语句初始化的。另外两个变量被初始化为它们自己的语句和值。**请记住,`is` 比较对象引用。如果它们相同,则返回 `True`。** + + +```py +>>> id(a), id(b), id(c), id(d) +(2267170738432, 2267170738432, 2267170545600, 2267170359040) + +``` + +由于 `a` 和 `b` 是同一个对象,在对其进行比较的时候,我们才会得到 `True`。其他是不同对象,因此是 `False`。 + + +## nan == nan[¶](#nan-nan "Permanent link") + +`nan`,或者说“非数字(Not a Number)”是一个浮点值,它无法被转换为浮点数以外的任何值,并且被视为不等于所有其他值。这是表示数据集中缺失值的常见方法。 + +上面的描述中有一个关键短语,它是这个陷阱的基础: +> +> is considered not equal to all other values(被视为不等于所有其他值) +> + +软件通常会在采取操作之前检查两个值是否彼此相等。对于 `nan`,这不起作用: + +```py +>>> float('nan') == float('nan') +False + +``` + +这可以防止这样的代码进入 `if/else` 语句的 `if` 块。 + + +```py +>>> a = float('nan') +>>> b = float('nan') +>>> if a == b: +... .. ## Do something if equal +... else: +... .. ## Do something if not equal + +``` + +在这个例子中,它们*永远*不相等。 + +这导致了一种有意思的(如果不是不直观的话)检查变量是否是 `nan` 值的方法。由于 `nan` 不等于所有其他值,因此它也不等于自身。 + +```py +>>> a != a +True + +``` + +就像我说的,“有意思”。但是,当其他人查看您的代码时,它也会“令人困惑”。有一种更简单的方法可以表明您正在检查一个 `nan` 值。[`isnan`](https://docs.python.org/3/library/math.html#math.isnan) + + +```py +>>> import math +>>> a = float('nan') +>>> b = 5 +>>> c = float('infinity') +>>> math.isnan(a) +True +>>> math.isnan(b) +False +>>> math.isnan(c) +False + +``` + +对我来说,这是一个更清晰的检查,我们想看看该值是否为 `nan`。 您可能不只是传递 `nan` 给单个变量。你可能正在使用诸如 [NumPy](https://numpy.org/) 或者 [Pandas](https://pandas.pydata.org/) 这样的库。在这种情况下,每个库都自带了一些函数,你可以用它们来完美检查 `nan`。 + + +* 在 NumPy 中,这个函数具有相同的名字,但是是在 NumPy 库中的:`numpy.isnan(value)`。 +* 在 Pandas 中,这个函数具有一个稍微不同的名字:`pandas.isna(value)` + + +### 总结[¶](#conclusion "Permanent link") + +比较并不总是像我们希望的那样直接。我在这里介绍了 Python 中的一些常见比较问题。 + +浮点比较在各种语言中都很常见。Python 有几种方法可以让开发人员更轻松地做到这一点。我建议使用 `isclose`,因为它可以使代码更加简洁,并且在使用该模块时无需像 `Decimal` 模块那样将数字包装在字符串中 + +`is` 应该*只*用于检查两个项目是否引用同一个对象。在任何其他情况下,它都不会执行您希望它执行的检查。 + +最后,`nan`等于*没有别的*。在开始将数据集中的值相互比较之前,了解这一点很重要。 \ No newline at end of file diff --git "a/Python Common/\344\270\272\344\273\200\344\271\210 Python \344\273\243\347\240\201\345\234\250\345\207\275\346\225\260\344\270\255\350\277\220\350\241\214\345\276\227\346\233\264\345\277\253\357\274\237.md" "b/Python Common/\344\270\272\344\273\200\344\271\210 Python \344\273\243\347\240\201\345\234\250\345\207\275\346\225\260\344\270\255\350\277\220\350\241\214\345\276\227\346\233\264\345\277\253\357\274\237.md" new file mode 100644 index 0000000..07c6f4d --- /dev/null +++ "b/Python Common/\344\270\272\344\273\200\344\271\210 Python \344\273\243\347\240\201\345\234\250\345\207\275\346\225\260\344\270\255\350\277\220\350\241\214\345\276\227\346\233\264\345\277\253\357\274\237.md" @@ -0,0 +1,317 @@ +原文:[why-does-python-code-run-faster-in-a-function.md](https://stackabuse.com/why-does-python-code-run-faster-in-a-function/) + +--- +## 介绍 + +Python 不一定以其速度而闻名,但有些东西可以帮助您从代码中榨取更多性能。令人惊讶的是,其中一种做法是在函数中而不是在全局范围内运行代码。在本文中,我们将了解为什么 Python 代码在函数中运行得更快以及 Python 代码执行的工作原理。 + + +## Python 代码执行 + +要理解为什么 Python 代码在函数中运行得更快,我们首先需要了解 Python 是如何执行代码的。Python 是一种解释性语言,这意味着它逐行读取并执行代码。当 Python 执行脚本时,它首先将其编译为字节码(一种更接近机器代码的中间语言),然后 Python 解释器再执行这些字节码。 + +```py +def hello_world(): + print("Hello, World!") + +import dis +dis.dis(hello_world) +``` + +``` + 2 0 LOAD_GLOBAL 0 (print) + 2 LOAD_CONST 1 ('Hello, World!') + 4 CALL_FUNCTION 1 + 6 POP_TOP + 8 LOAD_CONST 0 (None) + 10 RETURN_VALUE + +``` + +Python 中的 [dis](https://docs.python.org/3/library/dis.html) 模块将函数 `hello_world` 反汇编为字节码,如上所示。 + + +> **注意:** Python 解释器是执行字节码的虚拟机。默认的 Python 解释器是 CPython,它是用 C 编写的。还有其他 Python 解释器,如 Jython(用 Java 编写)、IronPython(用 .NET 编写)和 PyPy(用 Python 和 C 编写),但 CPython 是最常用的。 + + +## 为什么 Python 代码在函数中运行得更快 + +考虑一个简化的示例,其中包含一个迭代一系列数字的循环: + +```py +def my_function(): + for i in range(100000000): + pass + +``` + +编译此函数时,字节码可能如下所示: + +``` + SETUP_LOOP 20 (to 23) + LOAD_GLOBAL 0 (range) + LOAD_CONST 3 (100000000) + CALL_FUNCTION 1 + GET_ITER + FOR_ITER 6 (to 22) + STORE_FAST 0 (i) + JUMP_ABSOLUTE 13 + POP_BLOCK + LOAD_CONST 0 (None) + RETURN_VALUE + +``` + +这里的关键指令是 `STORE_FAST`,它用来存储循环变量 `i`。 + +现在让我们考虑一下,当循环位于 Python 脚本顶层时,字节码是怎么样的: + +``` + SETUP_LOOP 20 (to 23) + LOAD_NAME 0 (range) + LOAD_CONST 3 (100000000) + CALL_FUNCTION 1 + GET_ITER + FOR_ITER 6 (to 22) + STORE_NAME 1 (i) + JUMP_ABSOLUTE 13 + POP_BLOCK + LOAD_CONST 2 (None) + RETURN_VALUE + +``` + +请注意,这里使用了 `STORE_NAME` 指令,而不是 `STORE_FAST`。 + +字节码 `STORE_FAST` 比 `STORE_NAME` 快,因为在函数中,局部变量是存储在固定大小的数组中的,而不是存储在字典中。这个数组可通过索引直接访问,使得变量检索非常快。基本上,它只是对列表进行指针查找并增加 PyObject 的引用计数,这两者都是高效操作。 + +另一方面,全局变量存储在字典中。当访问全局变量时,Python 必须执行哈希表查找,其中涉及哈希值的计算,然后检索与其关联的值。尽管这些操作经过优化,但它本质上仍然比基于索引的查找慢。 + +## Python 代码的基准测试和分析 + +想亲自测试一下吗?尝试对您的代码进行基准测试和分析吧。 + +基准测试和分析是性能优化的重要实践。它们可以帮助您了解代码的行为方式以及瓶颈所在。 + +基准测试就是对代码进行计时以查看运行时间。您可以使用 Python 的内置 `time` [timeit](https://docs.python.org/3/library/timeit.html)。 + +另一方面,分析提供了代码执行的更详细视图。它向您显示大部分时间花在执行哪些代码、调用哪些函数以及调用频率。Python 的内置 [profile](https://docs.python.org/3/library/profile.html) 或者 [cProfile](https://docs.python.org/3/library/cProfile.html) 模块可用于此目的。 + +以下是分析 Python 代码的一种方法: + +```py +import cProfile + +def loop(): + for i in range(10000000): + pass + +cProfile.run('loop()') + +``` + +这将输出 `loop` 函数执行期间所有函数调用的详细报告。 + +> **注意:** 分析会给代码执行增加相当多的开销,因此分析器显示的执行时间可能会比实际执行时间长。 + + +## 分别在函数与全局范围内对代码进行基准测试 + +在 Python 中,代码执行的速度可能会根据代码的执行位置(在函数中还是在全局范围内)而有所不同。让我们用一个简单的例子来对两者进行比较。 + +考虑以下计算数字阶乘的代码片段: + +```py +def factorial(n): + result = 1 + for i in range(1, n + 1): + result *= i + return result + +``` + +现在让我们在全局范围内运行相同的代码: + +```py +n = 20 +result = 1 +for i in range(1, n + 1): + result *= i + +``` +为了对这两段代码进行基准测试,我们可以使用 Python 中的 `timeit` 模块,它提供了一种对少量 Python 代码进行计时的简单方法。 + +```py +import timeit + +# Factorial function here... + +def benchmark(): + start = timeit.default_timer() + + factorial(20) + + end = timeit.default_timer() + print(end - start) + +# +# Run benchmark on function code +# +benchmark() +# Prints: 3.541994374245405e-06 + +# +# Run benchmark on global scope code +# +start = timeit.default_timer() + +n = 20 +result = 1 +for i in range(1, n + 1): + result *= i + +end = timeit.default_timer() +print(end - start) +# Pirnts: 5.375011824071407e-06 + +``` + +您会发现函数代码比全局作用域代码执行得更快。这是因为由于我们之前讨论的原因,Python 执行函数代码的速度更快。 + + +> **注意:** 如果在同一个脚本中运行 `benchmark()` 函数和全局作用域代码,全局作用域代码会运行得更快。这是因为 `benchmark()` 函数增加了一些执行时间的开销,并且全局代码在内部还进行了一些优化。但是,如果单独运行它们,您会发现函数代码确实运行得更快。 + +## 分别在函数与全局范围内对代码进行分析 + +Python 提供了一个用于此目的的内置模块 `cProfile`。让我们用它来分析一个新函数,该函数在局部和全局范围内计算平方和。 + +```py +import cProfile + +def sum_of_squares(): + total = 0 + for i in range(1, 10000000): + total += i * i + +i = None +total = 0 +def sum_of_squares_g(): + global i + global total + for i in range(1, 10000000): + total += i * i + +def profile(func): + pr = cProfile.Profile() + pr.enable() + + func() + + pr.disable() + pr.print_stats() +# +# Profile function code +# +print("Function scope:") +profile(sum_of_squares) + +# +# Profile global scope code +# +print("Global scope:") +profile(sum_of_squares_g) +``` + +从分析结果中,您将看到函数代码在执行时间方面更加高效。 + +``` +Function scope: + 2 function calls in 0.903 seconds + + Ordered by: standard name + + ncalls tottime percall cumtime percall filename:lineno(function) + 1 0.903 0.903 0.903 0.903 profiler.py:3(sum_of_squares) + 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} + + +Global scope: + 2 function calls in 1.358 seconds + + Ordered by: standard name + + ncalls tottime percall cumtime percall filename:lineno(function) + 1 1.358 1.358 1.358 1.358 profiler.py:10(sum_of_squares_g) + 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} + +``` + +我们认为 `sum_of_squares_g()` 函数是全局的,因为它使用了两个全局变量 `i` 和 `total`。正如我们之前所看到的,全局变量会减慢代码执行速度,这就是我们在此代码中将这些变量设置为全局变量的原因。 + +## 优化 Python 函数性能 + +鉴于 Python 函数往往比全局范围内的等效代码运行得更快,因此值得研究如何进一步优化函数性能。 + +当然,由于我们之前看到的,一种策略是使用局部变量而不是全局变量。下面是一个例子: + +```py +import time + +# Global variable +x = 5 + +def calculate_power_global(): + for i in range(10000000): + y = x ** 2 # Accessing global variable + +def calculate_power_local(x): + for i in range(10000000): + y = x ** 2 # Accessing local variable + +start = time.time() +calculate_power_global() +end = time.time() + +print(f"Execution time with global variable: {end - start} seconds") + +start = time.time() +calculate_power_local(x) +end = time.time() + +print(f"Execution time with local variable: {end - start} seconds") + +``` + +在这个例子中,`calculate_power_local` 通常会比 `calculate_power_global` 跑得更快,因为它使用了一个局部变量,而不是全局变量。 + +``` +Execution time with global variable: 1.9901456832885742 seconds +Execution time with local variable: 1.9626312255859375 seconds +``` + +另一种优化策略是尽可能使用内置函数和库。Python 的内置函数是用 C 实现的,比Python快得多。同样的,许多 Python 库(例如 NumPy 和 Pandas)也是用 C 或 C++ 实现的,这使得它们比同等的 Python 代码更快。 + +例如,考虑这个对数字列表求和的任务。您可以编写一个函数来执行此操作: + +```py +def sum_numbers(numbers): + total = 0 + for number in numbers: + total += number + return total + +``` + +然而,Python 的内置 `sum` 函数也可以被用来做同样的事情,但它会更快: + +```py +numbers = [1, 2, 3, 4, 5] +total = sum(numbers) +``` +尝试自己计时这两个代码片段,并找出哪一个更快吧! + +## 总结 + +在本文中,我们探索了 Python 代码执行的有趣世界,特别关注为什么封装在函数中的 Python 代码往往运行得更快。我们简要介绍了基准测试和分析的概念,提供了如何在函数和全局范围内执行这些过程的实际示例。 + +我们还讨论了优化 Python 函数性能的几种方法。虽然这些技巧肯定可以使您的代码运行得更快,但您应该谨慎使用某些优化,因为平衡可读性、可维护性与性能是非常重要的。 \ No newline at end of file diff --git "a/Python Common/\347\216\260\345\256\236\344\270\255\347\232\204 match_case.md" "b/Python Common/\347\216\260\345\256\236\344\270\255\347\232\204 match_case.md" new file mode 100644 index 0000000..4c5f2eb --- /dev/null +++ "b/Python Common/\347\216\260\345\256\236\344\270\255\347\232\204 match_case.md" @@ -0,0 +1,133 @@ +原文:[Real-world match case](https://nedbatchelder.com/blog/202312/realworld_matchcase.html) + +--- + +Python 3.10 为我们带来了结构模式匹配,更广为人知的名称是 **match/case**。乍一看,它像来自 C 或 JavaScript 的 switch 语句,但其实有很大不同。 + +您可以使用 match/case 来匹配特定的文字,类似于 switch 语句的工作方式,但它们的目的是匹配数据结构中的模式,而不仅仅是值。[PEP 636:结构模式匹配:教程](https://peps.python.org/pep-0636/)很好地解释了其机制,但感觉就像一个玩具示例。 + +这是一个现实世界中的使用示例:在工作中,我们安装了一个 GitHub 机器人作为 Webhook。当我们的某个存储库发生了些什么时,GitHub 会向我们的机器人发送 JSON 格式的有效负载。机器人必须检查解码后的有效负载来决定要做什么。 + +这些有效负载很复杂:它们是只包含 6 或 8 个键的字典,但它们嵌套极深,最终包含数百条数据。最初我们将它们分开以查看它们有什么键值,但是 match/case 使工作变得更加简单。 + +以下是一些代码,用于确定当我们收到“comment created(评论已创建)”事件时要执行的操作: + +```py +# Check the structure of the payload: +match event: + case { + "issue": {"closed_at": closed}, + "comment": {"created_at": commented}, + } if closed == commented: + # This is a "Close with comment" comment. Don't do anything for the + # comment, because we'll also get a "pull request closed" event at + # the same time, and it will do whatever we need. + pass + + case {"sender": {"login": who}} if who == get_bot_username(): + # When the bot comments on a pull request, it causes an event, which + # gets sent to webhooks, including us. We don't have to do anything + # for our own comment events. + pass + + case {"issue": {"pull_request": _}}: + # The comment is on a pull request. Process it. + return process_pull_request_comment(event) +``` + +如果字典有一个“issue”键,值为一个带有“close_at”键的字典,并且还有一个“comment”键,值为一个带有“created_at”键的字典,并且字典中的这两个键值相等,则第一种情况匹配。在没有 match/case 的情况下要写出这种条件,代码会更加冗长和混乱。 + +第二种情况检查 event 以查看机器人是否是 event 的发起者。如果用不同的方式来写这个就不那么难了,但是 match/case 让代码更漂亮。 + +这正是 match/case 所擅长的:检查数据结构中的模式。 + +看看生成的字节码也很有趣。对于第一种情况,它看起来像这样: + +``` + 2 0 LOAD_GLOBAL 0 (event) + + 3 2 MATCH_MAPPING + 4 POP_JUMP_IF_FALSE 67 (to 134) + 6 GET_LEN + 8 LOAD_CONST 1 (2) + 10 COMPARE_OP 5 (>=) + 12 POP_JUMP_IF_FALSE 67 (to 134) + + 4 14 NOP + + 5 16 NOP + + 3 18 LOAD_CONST 8 (('issue', 'comment')) + 20 MATCH_KEYS + 22 POP_JUMP_IF_FALSE 65 (to 130) + 24 DUP_TOP + 26 LOAD_CONST 4 (0) + 28 BINARY_SUBSCR + + 4 30 MATCH_MAPPING + 32 POP_JUMP_IF_FALSE 64 (to 128) + 34 GET_LEN + 36 LOAD_CONST 5 (1) + 38 COMPARE_OP 5 (>=) + 40 POP_JUMP_IF_FALSE 64 (to 128) + 42 LOAD_CONST 9 (('closed_at',)) + 44 MATCH_KEYS + 46 POP_JUMP_IF_FALSE 62 (to 124) + 48 DUP_TOP + 50 LOAD_CONST 4 (0) + 52 BINARY_SUBSCR + 54 ROT_N 7 + 56 POP_TOP + 58 POP_TOP + 60 POP_TOP + 62 DUP_TOP + 64 LOAD_CONST 5 (1) + 66 BINARY_SUBSCR + + 5 68 MATCH_MAPPING + 70 POP_JUMP_IF_FALSE 63 (to 126) + 72 GET_LEN + 74 LOAD_CONST 5 (1) + 76 COMPARE_OP 5 (>=) + 78 POP_JUMP_IF_FALSE 63 (to 126) + 80 LOAD_CONST 10 (('created_at',)) + 82 MATCH_KEYS + 84 POP_JUMP_IF_FALSE 61 (to 122) + 86 DUP_TOP + 88 LOAD_CONST 4 (0) + 90 BINARY_SUBSCR + 92 ROT_N 8 + 94 POP_TOP + 96 POP_TOP + 98 POP_TOP + 100 POP_TOP + 102 POP_TOP + 104 POP_TOP + 106 STORE_FAST 0 (closed) + 108 STORE_FAST 1 (commented) + + 6 110 LOAD_FAST 0 (closed) + 112 LOAD_FAST 1 (commented) + 114 COMPARE_OP 2 (==) + 116 POP_JUMP_IF_FALSE 70 (to 140) + + 10 118 LOAD_CONST 0 (None) + 120 RETURN_VALUE + + 3 >> 122 POP_TOP + >> 124 POP_TOP + >> 126 POP_TOP + >> 128 POP_TOP + >> 130 POP_TOP + 132 POP_TOP + >> 134 POP_TOP + 136 LOAD_CONST 0 (None) + 138 RETURN_VALUE + + 6 >> 140 LOAD_CONST 0 (None) + 142 RETURN_VALUE +``` + +虽然很长,但您可以大致了解它在做什么:检查该值是否是包含至少两个键(字节码 2-12)的映射(字典),然后检查它是否包含我们将要检查的两个特定键( 18-22)。查看第一个键的值,检查它是否是一个至少有一个键(24-40)的字典,等等。 + +手写这些类型的检查可能会导致字节码更短。例如,我已经知道 event 的值是一个字典,因为这是 GitHub API 向我承诺的,因此无需每次都显式检查它。但 Python 代码会更加曲折且更难执行正确。我最初对 match/case 持怀疑态度,但这个例子显示了它的一个明显的优势。 \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_383.md b/Python Weekly/Python_Weekly_Issue_383.md new file mode 100644 index 0000000..2260ac4 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_383.md @@ -0,0 +1,139 @@ +原文:[Python Weekly - Issue 383](http://eepurl.com/ggyzub) + +--- + +欢迎来到Python周刊第 383 期。让我们直奔主题。 + +# 来自赞助商 +[![](https://gallery.mailchimp.com/e2e180baf855ac797ef407fc7/images/f25123ca-75a9-4b27-af3b-518500134fcd.png)](https://www.datadoghq.com/dg/apm/ts-python-tracing/?utm_source=Advertisement&utm_medium=Advertisement&utm_campaign=PythonWeekly-Tshirt&utm_content=Python) + +使用 Datadog APM 监控 Python 程序中的指标、日志和跟踪 —— 我们的跟踪客户端自动检测 Django、Redis 和其他框架及库,以便你可以立即洞悉。[通过 14 天的免费试用,亲身体验 Datadog 吧。](https://www.datadoghq.com/dg/apm/ts-python-tracing/?utm_source=Advertisement&utm_medium=Advertisement&utm_campaign=PythonWeekly-Tshirt&utm_content=Python). + + +# 新闻 + +[PyConWeb 2019 征求提议](https://www.papercall.io/pyconweb19) + +PyConWeb 2019 是第三届为期两天的会议,专注于 Python 的 Web 栈,它将于 5 月 25 日至 26 日在慕尼黑举行。非常欢迎每个人在 PyConWeb 上踊跃发言,此外,作为社区会议,我们在寻找那些愿意分享知识的人。 + +[PyCon 2019 提醒和信息!](https://pycon.blogspot.com/2019/01/pycon-2019-reminders-and-information.html) + + +# 文章,教程和讲座 + +[逐步将超过一百万行代码从 Python 2 迁移到 Python 3](https://blogs.dropbox.com/tech/2019/02/incrementally-migrating-over-one-million-lines-of-code-from-python-2-to-python-3/) + +在过去的几个月中,我们探讨了开展 Python 3 迁移的原因和方法,以及如何确保生成的应用是可靠的。在这篇文章中,我们将简要介绍我们的桌面客户端中关于 Python 3 的历史,然后深入了解我们是如何在允许持续开发的同时实现逐步迁移的。 + +[编程 Z3](https://theory.stanford.edu/~nikolaj/programmingz3.html) + +本教程提供了对于 Satisfiability Modulo Theories Solver Z3 的程序员介绍。它描述了如何通过脚本来使用 Z3,还描述了 Z3 中决策过程的几个算法。它旨在广泛涵盖 Z3 的几乎所有可用功能,以及底层算法的主要组成部分。 + +[详解链表与 Python 示例:单链表](https://stackabuse.com/linked-lists-in-detail-with-python-examples-single-linked-lists/) + +链表是所有编程语言中最常用的数据结构之一。在这篇文章中,我们将详细了解链表。我们将看到不同类型的链表,了解如何遍历链表、如何向链表插入元素以及将元素从链表中删除、对链表进行排序的不同技术、反转链表的方法等等。 + +[2018 年 Python 开发人员调查结果](https://www.jetbrains.com/research/python-developers-survey-2018/) + +由 Python 软件基金会和 JetBrains 发布的 2018 年官方 Python 开发人员调查结果:来自 150 多个国家的超过 2 万份回复。 + +[Keras:多输入和混合数据](https://www.pyimagesearch.com/2019/02/04/keras-multiple-inputs-and-mixed-data/) + +在这篇教程中,你将学习如何将 Keras 用于多输入和混合数据。你还将学习定义能够接受多种输入(包括数值、分类和图像数据)的 Keras 架构的方法。然后,我们将在此混合数据上训练单个端到端网络。 + +[使用 Python、Twilio 和 AWS 构建一个回忆物联网按钮罐](https://medium.com/@jman4190/building-a-jar-of-memories-iot-button-with-python-twilio-aws-ca90a8159bc3) + +如何点击遥远的按钮,然后通过文本发送喜爱的照片回忆。 + +[在 Jupyter Notebook 和 Python 中使用虚拟环境](https://janakiev.com/til/jupyter-virtual-envs/) + +你有在使用 Jupyter Notebook 和 Python 吗?你是否也想从虚拟环境中受益呢?在本教程中,你将了解如何使用 Anaconda 或者 Virtualenv/venv 来实现这一切。 + +[使用神经进化代理击败 OpenAI 游戏:非常简单!](http://declanoller.com/2019/01/25/beating-openai-games-with-neuroevolution-agents-pretty-neat/) + +[JupyterLab 入门](https://www.blog.pythonlibrary.org/2019/02/05/getting-started-with-jupyterlab/) + +[战略和命令涉及模式 —— 向导和三明治 —— Python 中的应用](https://medium.com/@rrfd/strategy-and-command-design-patterns-wizards-and-sandwiches-applications-in-python-d1ee1c86e00f) + +[和虚拟环境告别吗?](https://medium.com/@grassfedcode/goodbye-virtual-environments-b9f8115bc2b6) + +[使用 Keras,一次性学习 Siamese 网络](https://towardsdatascience.com/one-shot-learning-with-siamese-networks-using-keras-17f34e75bb3d) + + +# 书籍 + +[Python Flash Cards: Syntax, Concepts, and Examples(Python 记忆卡:语法、概念和示例)](https://amzn.to/2DX87Zy) + +随时随地保持你的编程技能!Python 记忆卡采用一种经过实践检验的方法,并对其进行编程改造。Eric Matthes,也就是畅销的 Python 速成课(Python Crash Course)的作者,将基本的 Python 编程知识提炼到这 101 张卡片组中,以便你可以随处使用。每次都可以按次或乱次使用,以便进行新的学习。通过它,你可以刷新基础的编程原理以及诸如数据结构、逻辑控制和程序流程这样的词汇,根据 Python 语法进行自我测试,并通过那些旨在让你保持警觉的练习和挑战测试你的技能 —— 所有这些,一本即可。 + + +# 本周的Python工作 + +[Beauhurst 招聘全栈 Web 开发](http://jobs.pythonweekly.com/jobs/grad-full-stack-web-developer-experience-0-yrs/) + + +# 好玩的项目,工具和库 + +[RustPython](https://github.com/RustPython/RustPython) +用 Rust 编写的 Python-3(CPython >= 3.5.0)解释器。 + +[gita](https://github.com/nosarthur/gita) + +并排管理多个 git 仓库,以确保完备性。 + +[Armory](https://github.com/depthsecurity/armory) + +Armory 是一个用于从许多工具中获取大量外部和发现数据,并将其添加到数据库,同时关联所有相关信息的工具。 + +[awesome-python-security](https://github.com/guardrailsio/awesome-python-security) + +棒棒哒的 Python 安全资源。 + +[gpu-sentry](https://github.com/jacenkow/gpu-sentry) + +监控 nVidia GPU 的使用情况的基于 Flask 的软件包。 + +[geometer](https://github.com/jan-mue/geometer) + +一个用 Python 写的几何库。 + +[pylane](https://github.com/NtesEyes/pylane) + +带调试工具的 python vm 注入器,基于 gdb。 + +[Output](https://gist.github.com/macournoyer/620a8ba4a2ecd6d6feaf) + +25 行代码的神经网络框架。 + +[XLM](https://github.com/facebookresearch/XLM) + +跨语言语言模型预训练的 PyTorch 原始实现。 + + +# 近期活动和网络研讨会 + +[San Francisco Python 2019 年 2 月聚会 - San Francisco, CA](https://www.meetup.com/sfpython/events/258401696/) + +将会有以下演讲: + + * 一举夺胜 Zork! + * 依赖管理 + * 当布尔值不够的时候……状态机? + + +[Boulder Python 2019 年 2 月聚会 - Boulder, CO](https://www.meetup.com/BoulderPython/events/xwblrpyzdbqb/) + +将会有一场演讲:不要使用我的 Grid 系统。 + +[IndyPy 2019 年 2 月每月聚会 - Indianapolis, IN](https://www.meetup.com/indypy/events/bxqbmqyzdbqb/) + +将会有以下演讲: + + * Python 中的 REST API + * 先了解,再行动 + * 将 Python 与 AWS 集成 + + +[Edmonton Python 2019 年 2 月聚会 - Edmonton, AB](https://www.meetup.com/startupedmonton/events/dtflxjyzdbpb/)  + +[Austin Python 2019 年 2 月聚会 - Austin, TX](https://www.meetup.com/austinpython/events/lgrbmqyzdbrb/) \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_384.md b/Python Weekly/Python_Weekly_Issue_384.md new file mode 100644 index 0000000..dde6de2 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_384.md @@ -0,0 +1,150 @@ +原文:[Python Weekly - Issue 384](http://eepurl.com/ghiX4f) + +--- + +欢迎来到Python周刊第 384 期。让我们直奔主题。 + +# 来自赞助商 +[![](https://gallery.mailchimp.com/e2e180baf855ac797ef407fc7/images/ab80f4a0-ba44-44fd-b19a-f5b56b2a9805.png)]( +https://www.vettery.com/tech?utm_source=newsletter&utm_medium=pythonweekly&utm_term=tech&utm_content=grouped&utm_campaign=ad-77579) + +[通过 Vettery 找到一份 Python 工作](https://www.vettery.com/tech?utm_source=newsletter&utm_medium=pythonweekly&utm_term=tech&utm_content=grouped&utm_campaign=ad-77579) + +Vettery是一个专门从事开发人员相关的在线招聘市场,并且对于求职者来说是完全免费的。感兴趣吗? 如果感兴趣的话,就提交您的个人资料,如果资料被接受,您就可以直接收到招聘 Python 开发人员的顶级公司的面试请求。 + + +# 新闻 + +[Python in Education - 寻求创意](https://pyfound.blogspot.com/2019/01/python-in-education-request-for-ideas.html) + +[PyCon 2020-2021 位置](https://pycon.blogspot.com/2019/02/pycon-2020-2021-location.html) + + +# 文章,教程和讲座 + +[给所有人看的机器学习](https://vas3k.com/blog/machine_learning/) + +简单易懂。带现实示例。是哒,再来一次。 + +[PSD2 兼容授权:使用 Python、Flask 和 Auth,验证敏感操作](https://www.twilio.com/blog/psd2-python-flask-authy-push) + +将双重验证(2FA)添加到你的登录过程中,以提高用户数据的安全性。我们还可以对其进行扩展,以验证敏感操作,例如从账户汇款、修改送货地址或者确认医疗预约。即使用户已经使用用户名密码登录了,我们也希望确保他们授权每一笔付款。这篇博文将向你展示如何使用 Python、Flask、一点点 Javascript 和 Authy API 来保护付款操作。 + +[通过重新发明理解神经网络和反向传播](https://medium.com/@interfacer/grok-neural-networks-backpropagation-by-re-inventing-them-a-hackers-guide-with-python-code-e7cc1daea04b) + +还有比通过(重新)发明或者发现某些东西来理解它们更好的方式吗?理解神经网络和基于错误梯度反向传播的学习背后的直觉知识和数据。用“黑客的方式”! + + +[学习 Python 直到够用:argparse](https://towardsdatascience.com/learn-enough-python-to-be-useful-argparse-e482e1764e05) + +如何在脚本中获取命令行参数。 + +[Python 打包现状](https://www.bernat.tech/pep-517-and-python-packaging/) + +描述当今 Python 打包机制的现状,以及 Python 打包管理局希望的下一步动作。 + +[语音助手样板和 API](https://medium.com/@dc.aihub/voice-assistant-boilerplate-api-146a4e8a9325) + +你可曾想过,“我要如何为网站制作一个专属语音助手?”,如果是的话,那么这篇文章就是为你而写的!我们将逐步指导你将 React 样板和 Python API 连接起来。而通过一些额外的研究,我们将实现的功能也可以很容易地部署到其他设备(例如树莓派)。 + +[如何用 Python 分析 SEO 数据:参考指南](https://www.searchenginejournal.com/python-seo-data-reference-guide/287927/) + +当没有工具可以帮忙的时候,Python 可以帮你消除重复的 SEO 任务。这里是一些实用的 SEO Python 应用。 + +[你会在泰坦尼克号事件中幸存吗?](https://hackernoon.com/would-you-survive-the-titanic-aa4ae2e86e9) + +永不沉没之旅 —— 人工智能可以在这场灾难中学到什么。 + +[使用 AMD GPU 和 Keras 训练神经网络](https://towardsdatascience.com/train-neural-networks-using-amd-gpus-and-keras-37189c453878) + +AMD 正在开发一种名为 ROCm 的新 HPC 平台。它的目标是创建一个通用的开源环境,能够同时与 Nvidia(使用 CUDA)和 AMD GPU 连接。本教程将解释如何在配置一个或多个 AMD GPU 的情况下设置一个神经网络环境。 + +[使用 Keras 和深度学习训练 Fashion MNIST](https://www.pyimagesearch.com/2019/02/11/fashion-mnist-with-keras-and-deep-learning/) + +在这篇教程中,你将学习如何使用 Keras 在 Fashion MNIST 数据集中训练一个简单的卷积神经网络(CNN),让你能够对时尚图像和类别进行分类。Fashion MNIST 数据集被普遍认为是(不太具有挑战性的)MNIST 数据集的一个(稍微具有挑战性的)直接替代品。 + +[如何用 Python 编写 Tendermint 应用](https://medium.com/coinmonks/how-to-write-tendermint-applications-using-python-d8dde304e339) + +[使用 Zeit 和 RDS Postgres 部署 Serverless Django](https://www.agiliq.com/blog/2019/02/django-zeit-now-serverless/) + +[如何在不到 50 行代码中构造一个聊天机器人](https://www.codingame.com/playgrounds/41655/how-to-build-a-chatbot-in-less-than-50-lines-of-code) + +[Python 异常被认为是反模式](https://sobolevn.me/2019/02/python-exceptions-considered-an-antipattern) + + +# 本周的Python工作 + +[DevOps / Python engineer at Gridium 招聘 DevOps / Python 工程师](http://jobs.pythonweekly.com/jobs/devops-python-engineer/) + + +# 好玩的项目,工具和库 + +[ptr](https://github.com/facebookincubator/ptr) + +Python Test Runner(ptr)生来就是在任意代码存储库中,以一种固有的方式运行测试。ptr 支持多 Python 项目(每个仓库在其 setup.(cfg|py) 文件中定义了单元测试)。通过使用单个测试虚拟环境,ptr 让开发者能够在一个 Python 环境中测试多个项目与模块。 + +[spektral](https://github.com/danielegrattarola/spektral) + +用于在 Keras 中进行关系表示学习的 Python 框架。 + +[Ludwig](https://github.com/uber/ludwig) + +Ludwig 是一个基于 TensorFlow 构建的工具箱,可以用来在不需要编写代码的情况下训练和测试深度学习模型。 + +[bert-embedding](https://github.com/imgarylai/bert-embedding) + +位于 mxnet 和 gluonnlp 之上的来自 BERT 模型的令牌级别嵌入。 + +[GPIOzero](https://github.com/RPi-Distro/python-gpiozero) + +使用树莓派 1 的一个简单的 GPIO 设备接口 + +[Cloud Annotations Training](https://github.com/cloud-annotations/training) + +自定义对象检测和分类训练。 + +[PythonEXE](https://github.com/jabbalaci/PythonEXE) + +如何从 Python 脚本创建可执行文件? + +[db-to-sqlite](https://github.com/simonw/db-to-sqlite) + +将来自任意 SQL 数据库的表或者查询导入到 SQLite 文件中的 CLI 工具。 + + +# 最新发布 + +[PyPy v7.0.0:2.7,3.5 和 3.6-alpha 的三重发布](https://morepypy.blogspot.com/2019/02/pypy-v700-triple-release-of-27-35-and.html) + +[Django 2.2 beta 1 发布](https://www.djangoproject.com/weblog/2019/feb/11/django-22-beta-1-released/) + +[Django 安全版本发布:2.1.6,2.0.11 和 1.11.19](https://www.djangoproject.com/weblog/2019/feb/11/security-releases/) + +[Django 错误修复版本:2.1.7,2.0.12 和 1.11.20](https://www.djangoproject.com/weblog/2019/feb/11/bugfix-releases/) + + +# 近期活动和网络研讨会 + +[IndyPy 自动化会议](https://2019.indypy.org/automate/) + +IndyPy Conf 开始了 2019 年的会议系列,其全天的演讲是关于将 Python 用于自动化、编排和物联网。快来了解使用 Python 的自动化流程。无论你是想减少耗费在重复性工作的时间,还是减少人为错误,我们都有适合你的主题。 + +[Boston Python 2019 年 2 月聚会 - Boston, MA](https://www.meetup.com/bostonpython/events/257225246/) + +将会有以下演讲: + + * WiFi 无源雷达 + * 在 Python 中使用 C/C++ 扩展 + + +[Django Boston 2019 年 2 月聚会 - Boston, MA](https://www.meetup.com/djangoboston/events/258890140/) + +将会有以下演讲: + + * Figures:开源轻量级分析仪表板 + * Django 的历史:为什么事情会是现在这个样子 + + +[PyHou 2019 年 2 月聚会 - Houston, TX](https://www.meetup.com/python-14/events/drtltlyzdbzb/) + +[快速演讲与演讲实践之夜!- New York, NY](https://www.meetup.com/nycpython/events/258461603/) \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_385.md b/Python Weekly/Python_Weekly_Issue_385.md new file mode 100644 index 0000000..dc21de4 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_385.md @@ -0,0 +1,133 @@ +原文:[Python Weekly - Issue 385](http://eepurl.com/gh2OkT) + +--- + +欢迎来到Python周刊第 385 期。让我们直奔主题。 + + +# 来自赞助商 +[![](https://gallery.mailchimp.com/e2e180baf855ac797ef407fc7/images/f25123ca-75a9-4b27-af3b-518500134fcd.png)](https://www.datadoghq.com/dg/apm/ts-python-tracing/?utm_source=Advertisement&utm_medium=Advertisement&utm_campaign=PythonWeekly-Tshirt&utm_content=Python) + +开始跨越服务边界追踪请求,对缓慢请求进行故障排除,并在几分钟内优化 Python 应用。[通过免费试用监控你的动态环境,并且 Datadog 还会送你一件 T 恤](https://www.datadoghq.com/dg/apm/ts-python-tracing/?utm_source=Advertisement&utm_medium=Advertisement&utm_campaign=PythonWeekly-Tshirt&utm_content=Python). + + +# 文章,教程和讲座 + +[使用 Keras 和深度学习进行乳腺癌分类](https://www.pyimagesearch.com/2019/02/18/breast-cancer-classification-with-keras-and-deep-learning/) + +在本教程中,你将学习如何使用 Keras、深度学习和 Python,对组织学图像中的乳腺癌进行分类。 + +[如何通过此 DIY 设置监控空气质量](https://medium.freecodecamp.org/how-to-monitor-your-air-quality-with-this-diy-setup-3399793137c3) + +通过树莓派、低成本气体传感器和遥控开关,你就可以控制家中的空气质量。 + +[使用 fbs 打包 PyQt5 应用](https://www.mfitzp.com/article/packaging-pyqt5-apps-with-fbs/) + +使用 fman 构建系统分发跨平台 GUI 应用。 + +[一个完整的 Python 机器学习项目演练](https://codequs.com/p/BkaLEq8r4/a-complete-machine-learning-project-walk-through-in-python) + +一个完整的 Python 机器学习项目演练:将机器学习各个部分组合在一起;模型选择;超参数调整以及评估;解释机器学习模型并展示结果。 + +[你应该知道的十个 Python 文件系统方法](https://towardsdatascience.com/10-python-file-system-methods-you-should-know-799f90ef13c2) + +通过 os 和 shutil 操作文件和文件夹。 + +[ARIMA 模型 —— Python 中的时间序列预测](https://www.machinelearningplus.com/time-series/arima-model-time-series-forecasting-python/) + +使用 ARIMA 模型,你可以通过序列过去的值来预测时间序列。在这篇文章中,我们会从头开始构建一个最优的 ARIMA 模型,并将其扩展为 Seasonal ARIMA(SARIMA)和 SARIMAX 模型。你还会了解如何使用 Python 构建自动模型。 + +[使用变分自动编码器建模电信客户流失](https://towardsdatascience.com/modeling-telecom-customer-churn-with-variational-autoencoder-4e5cf6194871) + +如何应用深度卷积神经网络和自动编码器来构建流失预测模型。 + +[使用 Python 进行蒙特卡洛模拟](https://pbpython.com/monte-carlo.html) + +使用 Python、pandas 和 numpy 进行蒙特卡洛模拟。 + +[为你的 Django 应用构建 AWS CodePipeline CI/CD](https://girisagar46.github.io/build-aws-codepipeline-for-cicd) + +在这篇文章中,你将学习如何为 Django 应用设置 AWS CodePipeline,以实现持续集成和持续交付(CI/CD)管道。 + +[别了,fsync():使用 Docker 进行快十倍的数据库测试](https://pythonspeed.com/articles/faster-db-tests/) + +一篇关于如何加速针对数据库运行测试,同时在 Docker 的帮助下仍然使用尽可能真实的环境的文章。 + +[使用 Apex Up 和 Aurora Serverless,部署完全 serverless 的 Django](https://www.agiliq.com/blog/2019/02/django-apex-up-serverless/) + +[Python 字符串格式化指南](https://kite.com/blog/python/python-string-formatting) + +[对于用 Python 进行网络爬取的 x86 和 ARM 较量](https://blog.dxmtechsupport.com.au/speed-test-x86-vs-arm-for-web-crawling-in-python/) + +[Python 的 str.isdigit vs. str.isnumeric](https://blog.lerner.co.il/pythons-str-isdigit-vs-str-isnumeric/) + + +# 本周的Python工作 + +[宾夕法尼亚大学招牌解决方案开发人员](http://jobs.pythonweekly.com/jobs/solutions-developer-bc/)  + +[dubizzle 招聘高级 Python 工程师](http://jobs.pythonweekly.com/jobs/senior-python-engineer-dubai/) + + +# 好玩的项目,工具和库 + +[planet](https://github.com/google-research/planet) + +深度规划网络:通过潜在动态规划学习,从像素进行控制。 + +[databases](https://github.com/encode/databases) + +Python 异步数据库支持。 + +[Tensorflow-Cookbook](https://github.com/taki0112/Tensorflow-Cookbook) +易于使用的简单 Tensorflow Cookbook。 + +[django-pg-timepart](https://github.com/chaitin/django-pg-timepart) + +支持 PostgreSQL 11 种时间范围和列表分区的 Django 扩展。 + +[TheSpaghettiDetective](https://github.com/TheSpaghettiDetective/TheSpaghettiDetective) + +用于 3D 打印机远程管理和监控的基于 AI 的故障检测。 + +[m2cgen](https://github.com/BayesWitnesses/m2cgen) + +将机器学习模型转换为零依赖的本地代码(Java、C、Python 等)。 + +[django-pivot](https://github.com/martsberger/django-pivot) + +用于透视 Django Queryset 的模块。 + +[Vocab](https://github.com/Mckinsey666/Vocab) + +与命令行集成的轻量级在线词典。无浏览器。无平装书。 + + +# 近期活动和网络研讨会 + +[Jupyter 社区研讨会 - Paris, France](https://blog.jupyter.org/jupyter-community-workshop-dashboarding-with-project-jupyter-b0e421bdf164) + +研讨会将持续四天,包括实际讨论、黑客环节和技术展示。该活动的目标是促进下游库作者和贡献者之间的协作和知识共享,并支持上游贡献。 + +[London Python 2019 年 2 月聚会 - London, UK](https://www.meetup.com/LondonPython/events/258870262/) + +将会有以下演讲: + + * 当深度学习遇见在线时尚 + * 网络应用消息传递协议 —— Python Web 开发的未来? + * 作为反模式导入 —— 解密 Python 中的依赖注入 + + +[IndyPy Bytes:集成 —— Indianapolis, IN](https://www.meetup.com/indypy/events/lbdfpqyzdbjc/) + +将会有一场演讲 —— Deeper Dive: 集成 Python 和 AWS。 + +[San Diego Python 2019 年 2 月聚会 - San Diego, CA](https://www.meetup.com/pythonsd/events/nmkqnqyzdblc/) + +将会有以下演讲: + + * Windows 中的 PyLauncher + * 使用 Python 进行更轻松的调度 + +[驯服隐藏态:Python 中的状态图 —— Philadelphia, PA](https://www.meetup.com/phillypug/events/258621609/) +  \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_386.md b/Python Weekly/Python_Weekly_Issue_386.md new file mode 100644 index 0000000..403a3be --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_386.md @@ -0,0 +1,139 @@ +原文:[Python Weekly - Issue 386](http://eepurl.com/giQEh1) + +--- + +欢迎来到Python周刊第 386 期。让我们直奔主题。 + + +# 来自赞助商 + +[![](https://gallery.mailchimp.com/e2e180baf855ac797ef407fc7/images/ab80f4a0-ba44-44fd-b19a-f5b56b2a9805.png)]( +https://www.vettery.com/tech?utm_source=newsletter&utm_medium=pythonweekly&utm_term=tech&utm_content=grouped&utm_campaign=ad-77579) + + +[通过 Vettery 找到一份 Python 工作](https://www.vettery.com/tech?utm_source=newsletter&utm_medium=pythonweekly&utm_term=tech&utm_content=grouped&utm_campaign=ad-77579) + +Vettery 是一个专攻开发者的在线招聘平台,对于求职人员而言完全免费。感兴趣吗?那就提交你的个人资料,如果通过的话,你将可以收到由那些寻找 Python 开发者的顶级公司发出的面试邀请。 + +# 文章,教程和讲座 + +[从头开始用 Python 构建一个数据分析库](https://www.youtube.com/playlist?list=PLVyhfExBT1XDTu-oocI3ttl_OPhulAJOp) + +学习如何使用 Python 从头开始构建数据分析库。沉浸在包含 40 个步骤和 100 次测试的综合项目中,你必须通过这些测试才能完成它。在这里,我们要构建的是 Pandas Cub,这是一个具有与 Pandas 库类似功能的库。 + +[通过聚类,找到图片的主色](https://www.dataquest.io/blog/tutorial-colors-image-clustering-python/) + +用代码分析图片可能很困难。你要怎样让你的代码“理解”一张图片的上下文呢? + +[你的第一个开源 Python 项目](https://towardsdatascience.com/build-your-first-open-source-python-project-53471c9942a7)  + +制作一个开源 Python 包可能听起来很吓人,但要做到这点,并不要求你经验相当丰富。并且,你也不需要精心设计的产品方案。真正需要的,是坚持和时间。希望这份指南能够帮助你减轻负担。 + +[使用 Python 和 Scikit-Learn,构建一个电影推荐引擎](https://medium.com/code-heroku/building-a-movie-recommendation-engine-in-python-using-scikit-learn-c7489d7cb145) + +想知道谷歌是怎么找到那些与你喜欢的电影相似的电影的吗?读过这篇文章,你就可以自己构建一个这样子的系统了。 + +[如何利用 Google Colab 来练习 Python 编程?](https://towardsdatascience.com/how-to-practice-python-with-google-colab-45fc6b7d118b) + +自动设置,及时获得帮助,协作式编程以及版本控制。一站式解决 Python 初学者练习中的痛点。 + +[如果编写 Python web 框架。第一部分](http://rahmonov.me/posts/write-python-framework-part-one/) + +这是编写像 Flask 和 Django 这样的 Python 框架系列的第一部分。在这个部分中,我们将实现以下功能:WSGI 兼容、请求处理器和请求路由:简单并且参数化 + + * [第二部分](http://rahmonov.me/posts/write-python-framework-part-two/) - 在此系列的第二部分,我们将实现这些功能:检查重复路由、基于类的处理器以及单元测试。 + + +[聊聊 Python 中的数据结构](https://apirobot.me/posts/lets-talk-about-data-structures-in-python) + +在这篇文章中,我们将讨论 python 最重要的数据结构。包括它们的工作方式、它们的使用场景以及使用方式。我们甚至会介绍一点点 Big-O 表示法,该表示法有助于描述算法和数据结构的有效性。 + +[即使某个功能你不使用,它也有可能坑你一把](https://blog.petrzemek.net/2019/02/22/even-feature-that-you-do-not-use-can-bite-you/) + +来看看我偶然编写,并且还在代码评审中看到过的一段简单的 Python 代码,它与预期全然不同。 + +[利用 OpenCV 和深度学习对黑白图像进行着色](https://www.pyimagesearch.com/2019/02/25/black-and-white-image-colorization-with-opencv-and-deep-learning/) + +[CPython Bytecode 编译器很蠢](https://nullprogram.com/blog/2019/02/24/) + +[Python 字典指南](https://kite.com/blog/python/python-dictionaries) + +[修复 Django 异步作业 —— 数据库集成](https://spapas.github.io/2019/02/25/django-fix-async-db/) + +[使用 Apache Airflow、Newspaper3k、Quilt T4 和 Vega 实现新闻头条的重复 NLP](https://medium.com/@robnewman/repeatable-nlp-of-news-headlines-using-apache-airflow-newspaper3k-quilt-t4-vega-a0447af57032) + +[Cython,超能秘密 Python 扩展介绍](http://okigiveup.net/an-introduction-to-cython/) + +[使用 Flask-Login 和 Flask-SocketIO 的单元测试应用](https://blog.miguelgrinberg.com/post/unit-testing-applications-that-use-flask-login-and-flask-socketio) + +[关于选择最小可能性的 Django ORM 优化之路](https://www.peterbe.com/plog/django-orm-optimization-story-on-selecting-the-least-possible) + + +# 本周的Python工作 + +[Cupboard 招聘后端软件工程师](http://jobs.pythonweekly.com/jobs/backend-software-engineer-nyc-or-sea/) + +[Wooga 招聘 Python 数据工程师](http://jobs.pythonweekly.com/jobs/data-engineer-python/) + + +# 好玩的项目,工具和库 + +[privacyIDEA](https://github.com/privacyidea/privacyidea) + +privacyIDEA 是一套开源解决方案,用于强双因素身份验证,如 OTP 令牌、SMS、智能手机或者 SSH 密钥。通过 privacyIDEA,你就可以使用第二因素强化现有应用的身份验证过程,例如本地登录(PAM,Windows 凭证提供程序)、VPN、远程访问、SSH 连接、网站或网络门户访问。 + +[Meltano](https://gitlab.com/meltano/meltano) + +Meltano 是一个面向配置的开源产品,适用于整个数据生命周期,包含从数据加载到数据分析的过程。 + +[bullet](https://github.com/Mckinsey666/bullet) + +轻松搞定漂亮的 Python 提示。就像堆叠块一样构建提示。 + +[SC-FEGAN](https://github.com/JoYoungjoo/SC-FEGAN) + +面部编辑生成对抗网络,使用用户草图和颜色。 + +[subsync](https://github.com/smacke/subsync) + +自动将字幕与视频同步。 + +[Polystores](https://github.com/polyaxon/polystores)  + +Polystores 是一种抽象以及一组与云存储交互的客户端。 + +[owoScript](https://github.com/ThePlasmaRailgun/owoScript) + +一个基于 OwO 的面向堆栈的编程语言。 + +[gitdir](https://github.com/sdushantha/gitdir) + +下载 GitHub 仓库中的单个目标或者文件夹。 + +[AdaBound](https://github.com/Luolc/AdaBound) + +一个训练速度如 Adam 般快速,功能如 SGD 一样好的优化器。 + +[message-analyser](https://github.com/vlajnaya-mol/message-analyser) + +VKontakte 和 Telegram 消息历史的统计分析。 + +# 最新发布 + +[Python 3.8.0a2](https://www.python.org/downloads/release/python-380a2/) + +[IPython 7.3](https://discourse.jupyter.org/t/release-of-ipython-7-3/409/1) + + +# 近期活动和网络研讨会 + +[New York Python 2019 年三月聚会 - New York, NY](https://www.meetup.com/nycpython/events/259044848/) + +将会有以下演讲: + + * Copilot @ Xaxis:使用 Python 和 Airflow,在大规模广告技术数据上实现 AI + * 为生产环境引进最先进的会话 AI NLP 栈 + * Runway:为涉及和创意平台添加机器学习功能 + + +[DFW Pythoneers 2019 年三月聚会 - Plano, TX](https://www.meetup.com/dfwpython/events/sbnhmqyzfbkb/) diff --git a/Python Weekly/Python_Weekly_Issue_617.md b/Python Weekly/Python_Weekly_Issue_617.md new file mode 100644 index 0000000..c973a2d --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_617.md @@ -0,0 +1,145 @@ +原文:[Python Weekly - Issue 617](http://eepurl.com/izHuCA) + +--- + +欢迎来到Python周刊第 617 期。让我们直奔主题。 + + +# 文章、教程和讲座 + +[向量嵌入教程 – 使用 GPT-4 和自然语言处理创建 AI 助手](https://www.youtube.com/watch?v=yfHHvmaMkcA) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) + +了解向量嵌入,以及如何在机器学习和人工智能项目中使用它们。了解如何使用矢量嵌入创建 AI 助手。 + +[Python 数据帧交换协议(Dataframe Interchange Protocol)是如何让生活更美好的](https://ponder.io/how-the-python-dataframe-interchange-protocol-makes-life-better/) + +在本文中,我们回答了有关 Python 数据帧交换协议的三个问题:它是什么 + 它解决了什么问题;它是怎么运行的; 以及它被广泛采用的程度。 + +[flake8-logging 介绍](https://adamj.eu/tech/2023/09/07/introducing-flake8-logging/) + +本文介绍 flake8-logging,一个可帮你改进 Python 代码中的日志记录的 Flake8 插件。Flake8 是一个检查 Python 代码是否有错误和样式违规的 linter。flake8-logging 通过添加检查日志代码的规则来扩展 Flake8。 + +[我们是如何使用 LLM 嵌入来构建 AI 搜索引擎的](https://www.youtube.com/watch?v=ZCPUmC37HLU) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) + +演示并解释如何使用 Python 的 sentence-transformers 库,通过 Django ORM 和 pgvector 来生成、存储和查询 LLM 嵌入。该视频演示了一个原型应用,这个应用可以使用求职者的非结构化英语描述来进行职位描述的“人工智能驱动搜索”。 + +[调试 Python 中正则表达式的灾难性回溯](https://krishnanchandra.com/posts/regex-catastrophic-backtracking/) + +这篇文章讨论了正则表达式中的灾难性回溯问题,并提供了一些有关如何避免该问题的提示。它还讨论了正则表达式引擎处理回溯的不同方式,以及不同方法之间的权衡。 + +[使用 Coiled、Dask 和 Xarray 处理 250 TB 数据集](https://blog.coiled.io/blog/coiled-xarray.html) + +作者使用 Xarray、Dask 和 Coiled,在 20 分钟内成功处理了大小为 250 TB 的地理空间云数据,强调了所涉及的挑战和优化,同时将成本保持在大约 25 美元左右。这一成就证明了大规模数据处理的可行性,暴露了可扩展性问题,并探索了此类任务的成本效益策略。 + +[使用 Kamal 部署 Django (mrsk)](https://anthonynsimon.com/blog/kamal-deploy/) + +如果你只想在远程计算机上部署容器,Kamal 可能是你工具带的一个不错的补充。将容器部署到一台或多台远程计算机时,它会自动执行许多常见步骤,而不会引入诸如 Kubernetes 这样的复杂性,也无需使用托管服务。 + +[使用 Django 和 HTMX 添加数据库搜索](https://www.photondesigner.com/articles/database-search-django-htmx) + +我们将使用 Django 和 HTMX 来创建快速且简单的数据库搜索。使用 HTMX 可以轻松快速地完成此操作。将有 6 个步骤。 + +[何时使用 Python 中的类?当您重复相同的函数时](https://death.andgravity.com/same-functions) + +在本文中,我们将了解在 Python 中使用类的另一种启发式方法,其中包含来自实际代码的示例以及一些需要记住的事项。 + +[迈向新的 SymPy:第 1 部分 - 概述](https://oscarbenjamin.github.io/blog/czi/post1.html) + +第一篇文章将概述像 SymPy 这样的计算机代数系统 (CAS) 的基础结构,描述 SymPy 目前存在的一些问题以及解决这些问题的方法。接着,后续的文章将更详细地关注特定组件、已完成的工作以及将来要做什么。 + * [第 2 部分 - 多项式](https://oscarbenjamin.github.io/blog/czi/post2.html) - 本文将描述 SymPy 的多项式计算代数系统,以及如何应用每个步骤来加速 SymPy。我会谈谈 FLINT 和 python-flint,但我也会写一篇关于这些的单独的文章,因为我知道有些人对使用 python-flint 比 SymPy 本身更感兴趣,我希望鼓励他们为 python-flint 做出贡献。 + + +[如何通过 PyObjC,使用 Apple Vision 框架进行文本识别](https://yasoob.me/posts/how-to-use-vision-framework-via-pyobjc/) + +本文讨论如何通过 PyObjC(允许你通过 Python 使用 Objective-C 框架),使用 Vision 框架。Vision 框架是一个机器学习框架,可用于执行人脸检测、对象检测和文本识别等任务。 + +[可视化 CPython 发布过程](https://sethmlarson.dev/security-developer-in-residence-weekly-report-9) + +[为模块改变 Python 属性处理](https://lwn.net/SubscriberLink/943619/eaa8a4496fcba1fd/) + +[如何使用 Python 和 Django 对类似于 Twitter 和 Instagram 的后续系统进行建模](https://uhtred.dev/insights/how-to-model-a-following-system-similar-to-twitter-and-instagram-with-python-and-django) + + +# 好玩的项目,工具和库 + +[Litestar](https://github.com/litestar-org/litestar) + +Litestar 是一个功能强大、灵活但有自己想法的 ASGI 框架,专注于构建 API,并提供高性能的数据验证和解析、依赖项注入、第一类(first-class)ORM 集成、授权原语以及启动和运行应用程序所需的更多功能。 + +[InstaGraph](https://github.com/yoheinakajima/instagraph) + +将文本输入或 URL 转换为知识图表并显示。 + +[Prompt flow](https://github.com/microsoft/promptflow) + +构建高质量的 LLM 应用 - 从原型设计、测试到生产部署和监控。 + +[kr8s](https://github.com/kr8s-org/kr8s) + +一个即拆即用(batteries-included)的 Kubernetes Python 客户端库,对于已经知道如何使用 kubectl 的人来说会感觉到很熟悉。 + +[Pyflyby](https://github.com/deshaw/pyflyby) + +一套 Python 生产力工具。 + +[pai](https://github.com/AlexWiles/pai) + +具有内置 AI 代理和代码生成功能的 Python REPL。 + +[view.py](https://github.com/ZeroIntensity/view.py) + +快如闪电的现代 Web 框架。 + +[django-send-sms](https://github.com/hizbul25/django-send-sms) + +只需编写一行代码,就可以使用任何短信服务提供商,从 Django 应用程序发送短信。 + +[WhatsApp-Llama](https://github.com/Ads-cmu/WhatsApp-Llama/) + +根据你的 WhatsApp 对话,微调 LLM,让它像您一样说话。 + +[textual-web](https://github.com/Textualize/textual-web) + +在浏览器中运行 TUI 和终端。 + +[LiteLLM](https://github.com/BerriAI/litellm) + +使用 OpenAI 格式,调用所有 LLM API(包括 Anthropic、Huggingface、Cohere、TogetherAI、Azure、OpenAI 等) + +[blip-caption](https://github.com/simonw/blip-caption) + +使用 Salesforce BLIP 为图像生成标题。 + +[Vanna](https://github.com/vanna-ai/vanna) + +个性化 AI SQL 代理。 + +[Medusa](https://github.com/FasterDecoding/Medusa) + +用于通过多个解码头加速 LLM 生成的简单框架。 + + +# 最新发布 + +[Visual Studio Code 中的 Python - 2023 年 9 月版本](https://devblogs.microsoft.com/python/python-in-visual-studio-code-september-2023-release/) + +此版本包括以下更新: +* Python 增加了“重新创建(Recreate)”或者“使用现有(Use Existing)”的选项:创建环境命令 +* 使用环境变量进行实验性终端激活 +* 社区贡献的 yapf 扩展 + + +# 近期活动和网络研讨会 + +[2023 年 9 月的 PyData Berlin Meetup](https://www.meetup.com/pydata-berlin/events/295877988/) + +将进行以下演讲: +* 随机梯度朗之万动力学(Stochastic Gradient Langevin Dynamics,SGLD) —— 动机、基础以及 DL 可以获得什么 +* OpenAI 开源语音识别模型Whisper:最先进的语音转录和语音界面革命 + + +[2023 年 9 月的 PyData Zurich Meetup](https://www.meetup.com/pydata-zurich/events/295909252/) + +将有以下演讲: +* 如何(不)在机器学习中使用公平性指标 +* 我们可以从 Python 的类型系统中挤出更多的东西吗?Tensor Shape Annotations 的挑战。 \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_618.md b/Python Weekly/Python_Weekly_Issue_618.md new file mode 100644 index 0000000..5ec33c6 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_618.md @@ -0,0 +1,160 @@ +原文:[Python Weekly - Issue 618](http://eepurl.com/iz-KzU) + +--- + +欢迎来到Python周刊第 618 期。让我们直奔主题。 + + +# 文章、教程和讲座 + +[为了好玩,将 ML 模型编译为 C](https://bernsteinbear.com/blog/compiling-ml-models/) + +ML 模型可以编译为图形,从而被用来遍历以执行前向和后向传递。这种方法可以提高性能并使调试 ML 模型变得更加容易。 + +[从数据集角度优化 LLM](https://sebastianraschka.com/blog/2023/optimizing-LLMs-dataset-perspective.html) + +本文重点介绍如何使用精心制作的数据集对 LLM 进行微调,从而提高 LLM 的建模性能。具体来说,本文重点介绍了涉及修改、利用或操作数据集以进行基于指令的微调的策略,而不是更改模型架构或训练算法(后者将是未来文章的主题)。本文还会解释如何准备自己的数据集来微调开源LLM。 + +[为什么有这么多 Python 数据帧(DataFrame)?](https://ponder.io/why-are-there-so-many-python-dataframes/) + +这篇文章探讨了 Python 数据帧(DataFrame)的激增,剖析了它们在数据科学和分析中盛行背后的原因,揭示了有助于丰富其内容的各种库和框架。 + + +[我手工制作了一个 Transformer(无需训练!) ](https://vgel.me/posts/handmade-transformer/) + +本文深入探讨了如何创建手工制作的 Transformer 模型,提供了从头开始构建这种流行的深度学习架构的详细演练,深入了解了其内部工作原理和结构。 + +[EuroPython 2023 视频](https://www.youtube.com/playlist?list=PL8uoeex94UhFcwvAfWHybD7SfNgIUBRo-) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) + +这里是由 EuroPython 2023 团队和 EuroPython 协会为您带来的会议的所有视频。 + +[如何在 6 分钟内向 Django 添加无服务器函数(使用 HTMX 和 AWS Lambda)](https://www.photondesigner.com/articles/serverless-functions-django) + +本文讨论无服务器函数(serverless functions)与 Django 的集成,重点介绍开发人员可以如何利用无服务器计算(serverless computing)的优势来执行 Django 应用程序中的特定任务。它探讨了无服务器架构的优势,并为实现提供了实用的见解。 + +[使用 Python 模拟蒙提霍尔问题(Monty Hall problem)](https://www.dataschool.io/python-probability-simulation/) + +使用 Python 解决这个困扰数学家和诺贝尔奖获得者的经典概率难题! + +> Ele 注:[蒙提霍尔问题](https://zh.wikipedia.org/zh-hans/%E8%92%99%E6%8F%90%E9%9C%8D%E7%88%BE%E5%95%8F%E9%A1%8C) + +[PyO3 异常 🎦](https://www.youtube.com/watch?v=UaeOdVwNNpI) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) + +该视频讨论了使用 Rust 时,在 Python 中处理异常的问题。在 Rust 中,错误的处理方式不同,它使用响应类型,而 Python 则使用异常。该视频演示了如何通过创建 Python 异常实例并引发它,使用 Rust 在 Python 中引发异常。它还展示了如何通过使用映射函数将 Rust 错误转换为 Python 异常来处理异常。 + +[Django:将模板标签库移至内置模块中](https://adamj.eu/tech/2023/09/15/django-move-template-tag-library-builtins/) + +Django 的模板引擎有一个未被充分重视的内置选项,该选项可以选择要在每个模板中预加载的库。将库设为内置对象可以避免在使用其标签或过滤器时需要显式使用 {% load %} 标签。将关键库放入内置模块中可以缩短模板并使开发速度更快一些。在这篇文章中,我们将介绍如何向内置模块添加模板库以及如何从模板中删除现有的 {% load %} 标签。 + +[加速 Floyd-Steinberg 抖动:一个优化练习](https://pythonspeed.com/articles/optimizing-dithering/) + +一个已解决实例:优化低层代码以获得显着的性能和内存改进。 + +> Ele 注:根据google,Floyd-Steinberg抖动算法是图像抖动算法的一种,其思想是将误差传播到邻近的像素点。 Floyd-Steinberg算法思想是将误差传播到邻近的像素点,误差的计算非常简单,即误差为像素点灰度值与该像素点最后取值的差值。 + +[Python 初学者教程(带迷你项目)🎦](https://www.youtube.com/watch?v=qwAFL1597eM) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) + +在这个面向初学者的完整课程中学习 Python 编程。本教程自始至终都以迷你项目为特色,因此您可以立即将学到的知识运用到实践中。 + +[快 19 倍的响应时间](https://lincolnloop.com/insights/optimizing-response-time-19x-faster/) + +Lincoln Loop 优化了大型发布平台的数据库性能。总体而言,数据库性能提高了 19 倍。 + +[构建适用于生产的基于 RAG 的 LLM 应用程序(第 1 部分)](https://www.anyscale.com/blog/a-comprehensive-guide-for-building-rag-based-llm-applications-part-1) + +在本指南中,我们将学习如何开发和生产基于检索增强生成 (RAG) 的 LLM 应用程序,关注规模、评估和路由。 + + +# 好玩的项目,工具和库 + +[EvoDiff](https://github.com/microsoft/evodiff) +通过离散扩散模型生成蛋白质序列和进化比对。 + +[every-breath-you-take](https://github.com/kbre93/every-breath-you-take) +使用 Polar H10 监测仪进行心率变异训练。 + +[Galactic](https://github.com/taylorai/galactic) +Galicate 为海量非结构化文本数据集提供清理和管理工具。它旨在帮助您管理微调数据集、创建用于检索增强生成 (RAG) 的文档集合,甚至为 LLM 预训练进行网络规模数据集的重复数据删除。 + +[Logparser](https://github.com/logpai/logparser) +Logparser 为自动化日志解析(结构化日志分析的关键步骤)提供了一个机器学习工具包和基准 + +[HTTP-Shell](https://github.com/JoelGMSec/HTTP-Shell) +多平台 HTTP 反向 Shell。 + +[llm-guard](https://github.com/laiyer-ai/llm-guard) +用于 LLM 交互的安全工具包。 + +[Temporian](https://github.com/google/temporian) +Temporian 是一个 Python 库,用于机器学习应用中时态数据(例如时间序列、事务)的特征工程和数据增强。 + +[vpselector](https://github.com/manumerous/vpselector) +Visual Pandas Selector:可视化及交互式选择时间序列数据。 + +[QuasiQueue](https://github.com/tedivm/quasiqueue) +QuasiQueue 是一个 Python 多处理库,它使长时间运行的多进程作业变得非常容易。QuasiQueue 处理进程创建和清理、信号管理、跨进程通信以及所有其他让人讨厌处理多处理的糟心玩意。 + +[PyGraft](https://github.com/nicolas-hbt/pygraft) +触手可及的模式和知识图可配置生成。 + +[PYOBD](https://github.com/barracuda-fsh/pyobd) +开源 obd2 汽车诊断程序。 + +[reinette-II-plus-dot-py](https://github.com/ArthurFerreira2/reinette-II-plus-dot-py) +用 Python 实现的 Apple II 模拟器 + +[PyLLMCore](https://github.com/paschembri/py-llm-core) +提供轻量级 LLM 的 python 库。 + +[HomeHarvest](https://github.com/ZacharyHampton/HomeHarvest) +用于房地产抓取的 Python 包,支持 Zillow,Realtor.com 和 Redfin。 + + +# 最新发布 + +[Django 5.0 alpha 1 发布](https://www.djangoproject.com/weblog/2023/sep/18/django-50-alpha-1-released/) + +[Python 3.12.0 候选版本 3 现已推出](https://pythoninsider.blogspot.com/2023/09/python-3120-release-candidate-3-now.html) + + +# 近期活动和网络研讨会 + +[2023 年 9 月 PyLadies 伦敦研讨会](https://www.meetup.com/pyladieslondon/events/295976344/) + +将有以下演讲: + + * 外部技术:在工程师和非工程师之间架起桥梁 + * 使用 Django 进行快速原型设计 + + +[2023 年 9 月 Python 巴塞罗那研讨会](https://www.meetup.com/python-barcelona/events/296203267/) + +将有以下演讲: + + * 向量化Python表达式中的两种语言问题 + * AI图像生成算法在服装设计中的应用 + + +[2023 年 9 月 PyLadies 巴黎研讨会](https://www.meetup.com/pyladiesparis/events/295911409/) + +将有以下演讲: + + * 机器学习和因果推断:寻找新的临床证据? + * 项目反馈:减少权限管理时间,同时保护您的用户! + + +[2023 年 9 月 VilniusPy 研讨会](https://www.meetup.com/vilniuspy/events/296100222/) + +将有以下演讲: + + * 我们是如何将我们的 Django 测试套件加速 10 倍的 + * Python 生成器:内存占用少,功耗大 + * Deadcode —— 一个查找和修复死的(未使用)Python 代码的工具 + + +[2023 年 9 月 PyData 斯德哥尔摩研讨会](https://www.meetup.com/pydatastockholm/events/295730658/) + +将有以下演讲: + + * 如何通过桥接跨领域知识来开发正确的解决方案,从而实现人工智能的价值? + * 自动化一切:使用 Python 扩展 Voi 的 dbt 功能 \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_619.md b/Python Weekly/Python_Weekly_Issue_619.md new file mode 100644 index 0000000..6bd93e9 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_619.md @@ -0,0 +1,105 @@ +原文:[Python Weekly - Issue 619](http://eepurl.com/iAEiz6) + +--- + +欢迎来到Python周刊第 619 期。让我们直奔主题。 + + +# 文章、教程和讲座 + +[Mojo 编程语言 —— 给初学者的完整课程](https://www.youtube.com/watch?v=5Sm9IVMet9c) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在这个完整教程中学习 Mojo。Mojo 编程语言结合了 Python 的可用性和 C 的性能。它基本上是专为人工智能开发人员设计的 Python 增强版本。 + +[在 git 存储库中,您的文件位于哪里?](https://jvns.ca/blog/2023/09/14/in-a-git-repository--where-do-your-files-live-/) +这篇文章探讨了 Git 存储库的内部工作原理,揭示了文件在存储库结构中的存储位置。它深入解释了对 Git 对象模型及其管理文件版本的方式。 + +[语言模型的黑客指南](https://www.youtube.com/watch?v=jkrNMKz9pWU) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在这段内容丰富的视频中,fast.ai 联合创始人兼所有现代语言模型 (LM) 所基于的 ULMFiT 方法的创建者 Jeremy Howard 将带您全面了解 LM 的迷人景象。Jeremy 从基本概念开始,介绍了使这些人工智能系统发挥作用的架构和机制。然后,他深入讲述了 GPT-4 的关键评估,阐明了语言模型在代码编写和数据分析中的实际用途,并提供了使用 OpenAI API 的实践技巧。该视频还提供了有关技术主题的专家指导,例如微调、解码令牌和运行 GPT 模型的私有实例。 + +[Asyncio 协程比线程快!?](https://superfastpython.com/asyncio-coroutines-faster-than-threads/) +在本教程中,您将在给定一组基准测试的情况下,看看协程是否真的比线程更快。 + +[为 Django ORM 构建 RisingWave 连接器](https://bas.codes/posts/django-risingwave) +曾经想过将流数据库连接到 Django ORM 吗?那就来了解如何使用 Django 和 RisingWave 吧。 + +[我用 ChatGPT 打造了一位人工智能医生 —— 完整的临床经验](https://www.youtube.com/watch?v=EAger7jOrsA) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该软件旨在测试人工智能执行患者入院、图表注释以及提供调查和诊断援助的能力。然而,值得注意的是,该软件尚未经过美国食品和药物管理局 (FDA) 或任何其他医疗设备监管机构的测试、验证或批准。 + +[Seaborn 混淆矩阵:如何用 Python 绘图和可视化](https://www.marsja.se/seaborn-confusion-matrix-how-to-plot-and-visualize-in-python/) +通过 Seaborn 混淆矩阵绘图掌握数据可视化的艺术。像专业人士一样评估模型性能。 + +[通过基于角色的权限,使内容管理者的 Django 管理员访问权限保持最新状态](https://406.ch/writing/keep-content-managers-admin-access-up-to-date-with-role-based-permissions/) +使用 Django 基于角色的权限系统,您可以通过仅授予内容管理者所需的权限,来使内容管理者的管理员访问权限保持最新状态。这可以通过使用基于白名单的方法来完成,其中,用户默认没有权限,因此必须单独授予用户每个权限。 + +[为什么 Python 代码在函数中运行得更快?](https://stackabuse.com/why-does-python-code-run-faster-in-a-function/) +Python 不一定以其速度而闻名,但有些东西可以帮助您从代码中榨取更多性能。令人惊讶的是,其中一种做法是在函数中而不是在全局范围内运行代码。在本文中,我们将看到为什么 Python 代码在函数中运行得更快,以及 Python 代码执行的工作原理。 + +[GPT Engineer 真的有用吗?](https://www.youtube.com/watch?v=NLgw19X8p7I) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频探讨了 GPT Engineer 的功能,这是一种新的 AI 编码工具,可以为多种编程语言生成代码。它评估了使用 GPT Engineer 的优缺点,并讨论了如何使用它为新项目快速生成样板代码。该视频还比较了 GPT 3.5 和 GPT 4,这是 GPT Engineer 所基于的两种大型语言模型。 + +[在无法使用多核时加速代码](https://pythonspeed.com/articles/optimizing-dithering/) +并行并不是唯一的答案:通常您可以优化低级代码以获得显着的性能改进。 + +[开始 CPython 的软件物料清单(SBOM)](https://sethmlarson.dev/security-developer-in-residence-weekly-report-12) + +[那么,你想公开数据库吗?—— 一次自动 API 生成的探索](https://codebeez.nl/blogs/so-you-want-to-expose-a-database-an-exploration-of-automated-api-generation/) + +[用不到 10 行代码,使用 GZI P,达到 78% MNIST 准确率。](https://jakobs.dev/solving-mnist-with-gzip/) + +[小但快:使用 Flask、htmx 和 Airtable 进行如闪电般的快速搜索(无需 React)。](https://levelup.gitconnected.com/small-and-speedy-lightning-fast-search-with-flask-htmx-and-airtable-no-react-required-f10b40785bf3) + + +# 好玩的项目,工具和库 + +[magentic](https://github.com/jackmpcollins/magentic) +将 LLM 无缝集成为 Python 函数。 + +[vizro](https://github.com/mckinsey/vizro) +Vizro 是一个用于创建模块化数据可视化应用程序的工具包。 + +[SeaGOAT](https://github.com/kantord/SeaGOAT) +本地优先语义代码搜索引擎。 + +[dify](https://github.com/langgenius/dify) +一个用于插件和数据集的 API,一个用于快速工程和可视化操作的界面,所有这些都用于创建强大的 AI 应用程序。 + +[FastStream](https://github.com/airtai/faststream) +FastStream 是一个功能强大且易于使用的 Python 框架,用于构建与 Apache Kafka 和 RabbitMQ 等事件流交互的异步服务。 + +[rustworkx](https://github.com/Qiskit/rustworkx) +一个用 Rust 实现的高性能 Python 图形库。 + +[shshsh](https://github.com/zqqqqz2000/shshsh) +python 和 shell 之间的桥梁。 + +[Medical_Intake](https://github.com/daveshap/Medical_Intake) +用于医疗摄入、诊断、测试等的自动化管道 + +[automatic_log_collector_and_analyzer](https://github.com/Dicklesworthstone/automatic_log_collector_and_analyzer) +用这一奇技淫巧取代您小公司中的 Splunk! + +[pythex](https://pythex.org/) +pythex 是测试 Python 正则表达式的快速方法。 + +[PyMilo](https://github.com/openscilab/pymilo) +PyMilo 提供了一种导出预训练机器学习模型的方法。这使得在其他环境中使用模型、跨不同平台传输模型以及与其他人共享模型成为可能。 + + +# 近期活动和网络研讨会 + +[PyBay2023](https://pybay.com/) +想和朋友一起出去并享受美食和饮料吗?参加 PyBay2023 吧,这是第八届年度区域 Python 会议,有 25 场演讲! + +[PyData 伦敦 2023年10月研讨会](https://www.meetup.com/pydata-london-meetup/events/295029812/) +将会有以下演讲: + * 使用这一奇技淫巧创建自助数据 + * Unicode 历险记:鲜为人知的 `str` + * Polars 最疯狂的特性:字节码解析 + * 设置您自己的 ML 集群 + + +[PyRVA 2023年10月研讨会](https://www.meetup.com/pyrvausergroup/events/295802864/) +会一场演讲:掌握 Selenium 以提高网络浏览器自动化效率。 + +[Hybrid: PyConZA 2023](https://za.pycon.org/) +PyConZA 是南非社区使用和开发开源 Python 编程语言的年度聚会。 diff --git a/Python Weekly/Python_Weekly_Issue_620.md b/Python Weekly/Python_Weekly_Issue_620.md new file mode 100644 index 0000000..acf0ae8 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_620.md @@ -0,0 +1,96 @@ +原文:[Python Weekly - Issue 620](http://eepurl.com/iA9nDI) + +--- + +欢迎来到Python周刊第 620 期。让我们直奔主题。 + + +# 文章、教程和讲座 + +[Python 3.12:您需要了解的所有新功能!](https://www.youtube.com/watch?v=udHmeAmOlbI) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频不仅将深入探讨 Python 3.12 中即将推出的令人兴奋的新功能和改进,还将讨论即将发布的版本中将删除的一些东西。 + +[度量 Python 执行时间的 5 种方法](https://superfastpython.com/benchmark-execution-time/) +您可以使用标准库中的“time”模块对 Python 代码的执行进行基准测试。在本教程中,您将了解如何使用一套不同的技术来计时 Python 代码的执行时间。 + +[使用 FastAPI 掌握集成测试](https://alex-jacobs.com/posts/fastapitests/) +集成测试 FastAPI:使用 MongoMock、MockS3 等来利用模拟后端服务的强大功能。 + +[LangChain 初始者速成班](https://www.youtube.com/watch?v=lG7Uxts9SXs) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +LangChain 是一个旨在简化使用大型语言模型创建应用程序的框架。它让你能够轻松地将 AI 模型与大量不同的数据源连接起来,以便您可以创建定制的 NLP 应用程序。 + +[使用 Django REST 框架构建 API](https://blog.jetbrains.com/pycharm/2023/09/building-apis-with-django-rest-framework/) +本教程演示了如何在 PyCharm 中使用 Python 和 Django REST 框架来开发 API + +[我所学到的有关在 Python 中构建 CLI 工具的那些事](https://simonwillison.net/2023/Sep/30/cli-tools-python/) +我用 Python 构建了很多命令行工具。它已成为我最喜欢的快速将一段代码变成我可以自己使用并打包供其他人使用的方法。以下是我迄今为止在 Python 中设计和实现 CLI 工具所学到的一些东西的笔记。 + +[用不到 200 行代码在云中构建 API](https://aeturrell.com/blog/posts/build-a-cloud-api/build-a-cloud-api.html) +云工具和 Python 包已经变得非常强大,让您可以用不到 200 行代码构建(可扩展的)基于云的 API。在本文中,您将了解如何使用 Google Cloud、Terraform 和 FastAPI,在云上部署可查询数据 API。 + +[如何在 Django 中安全存储用户的 API 密钥](https://www.photondesigner.com/articles/store-api-keys-securely) +加密用户的密钥以提高安全性。 + +[使用 PyTorch Lightning 扩展大型(语言)模型](https://lightning.ai/blog/scaling-large-language-models-with-pytorch-lightning/) +了解使用 PyTorch Lightning 训练 Llama 和 Stable Diffusion 等大型模型的技术。 + +[探索 Wordle](https://www.georgevreilly.com/2023/09/26/ExploringWordle.html) +本文将向您展示如何使用 Python,以编程方式解决 Wordle。 + + +# 好玩的项目,工具和库 + +[mistral-src](https://github.com/mistralai/mistral-src) +Mistral AI 7B v0.1 模型的参考实现。 + +[kernel-hardening-checker](https://github.com/a13xp0p0v/kernel-hardening-checker) +用于检查 Linux 内核安全强化选项的工具。 + +[dreamgaussian](https://github.com/dreamgaussian/dreamgaussian) +用于高效 3D 内容创建的生成 Gaussian Splatting。 + +[cloud_benchmarker](https://github.com/Dicklesworthstone/cloud_benchmarker) +Cloud Benchmarker 自动化执行云实例的性能测试,提供富有洞察力的图表并随时间进行跟踪。 + +[DSPy](https://github.com/stanfordnlp/dspy) +使用基础模型进行编程的框架。 + +[cloudgrep](https://github.com/cado-security/cloudgrep) +cloudgrep 是用于云存储的 grep。 + +[Octogen](https://github.com/dbpunk-labs/octogen) +Octogen 是一款由 GPT3.5/4 和 Codellama 提供支持的开源代码解释器。 + +[stepping](https://stepping.site/) +给 Python 应用开发者的增量视图维护。 + +[BoTorch](https://botorch.org/) +BoTorch 是一个基于 PyTorch 构建的贝叶斯优化研究库。 + +[cappa](https://github.com/dancardin/cappa) +声明式 CLI 参数解析器。 + +# 最新发布 + +[Python 3.12.0](https://www.python.org/downloads/release/python-3120/) +Python 3.12.0 中的一些主要变化包括 + * 更灵活的 f 字符串解析 + * Python 代码对缓冲区协议的支持 + * 新的调试/分析 API + * 支持具有单独全局解释器锁(GIL)的隔离子解释器 + * 更多改进的错误消息。 + * 支持 Linux 性能分析器报告跟踪中的 Python 函数名称。 + * 许多大大小小的性能改进 + +[Flask 3.0.0](https://flask.palletsprojects.com/en/3.0.x/changes/) + +[Django 安全版本已发布:4.2.6、4.1.12 和 3.2.22](https://www.djangoproject.com/weblog/2023/oct/04/security-releases/) + + + # 近期活动和网络研讨会 + +[Hybrid IndyPy - 利用 AI 进行创新:构建类似 ChatGPT 的应用程序](https://www.meetup.com/indypy/events/294548715/) +希望通过创建自己的类似 ChatGPT 的应用程序来释放 AI 和 LLM 的潜力吗?在本次演讲和现场演示中,您将学习如何提取专有数据见解、加速数据驱动的决策、提高生产力并推动创新。 + +[虚拟(Virtual):克利夫兰 Python 2023 年 10 月聚会](https://www.meetup.com/cleveland-area-python-interest-group/events/295681934/) +将有一场演讲:使用网络抓取,解析和收集亚马逊产品列表的评论数据。 diff --git a/Python Weekly/Python_Weekly_Issue_621.md b/Python Weekly/Python_Weekly_Issue_621.md new file mode 100644 index 0000000..66475e4 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_621.md @@ -0,0 +1,101 @@ +原文:[Python Weekly - Issue 621](http://eepurl.com/iBCBtY) + +--- + +欢迎来到Python周刊第 621 期。让我们直奔主题。 + + +# 文章、教程和讲座 + +[几分钟内构建您的第一个 Pytorch 模型!](https://www.youtube.com/watch?v=tHL5STNJKag) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在本视频中,我们将通过实践来学习!构建您的第一个 PyTorch 模型(可以对扑克牌图像进行分类)。 + +[使用单个 GPU,在 Python 代码上微调 Mistral7B!](https://wandb.ai/byyoung3/ml-news/reports/Fine-Tuning-Mistral7B-on-Python-Code-With-A-Single-GPU---Vmlldzo1NTg0NzY5) +虽然 Mistral 7B 的开箱即用令人印象深刻,但其微调能力仍有巨大潜力。本教程旨在指导您完成针对特定用例(Python 编码)微调 Mistral 7B 的过程!我们将利用 HuggingFace 的 Transformers 库、DeepSpeed(用于优化)和 Choline(用于简化在 Vast.ai 上部署)等强大工具。 + +[使用 Python 管道方法,优雅地进行模块化数据处理](https://github.com/dkraczkowski/dkraczkowski.github.io/tree/main/articles/crafting-data-processing-pipeline) +深入研究错综复杂的数据处理通常感觉就像在错综复杂的迷宫中航行。我们构建了这些复杂的流程,却只是为了避免破坏它们而对其保持原样。但如果我们可以改进它呢?以下是我对用 Python 构建更易于维护、模块化的数据处理工作流程的看法,该工作流程倾向于“管道和过滤器”架构模式。 + +[使用 Pandas Dropna 处理缺失数据](https://ponder.io/professional-pandas-handling-missing-data-with-pandas-dropna/) +在这篇文章中,我们将通过探索世界幸福报告来学习如何使用 pandas dropna 处理缺失数据。 + +[从 Python 调用 Rust](https://blog.frankel.ch/rust-from-python/) +从这篇文章学习从 Python 调用 Rust 的三种不同方法:HTTP、IPC 和 FFI。 + +[如何在 SaaS 平台中使用 LLM](https://www.youtube.com/watch?v=fH8fJYWfJcg) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频将引导您了解在名为 Learntail 的 SaaS 平台中使用了多大的语言模型。Learntail 是一款易于使用的人工智能测验生成工具。 + +[Django 中的 RegisterFields](https://www.better-simple.com/django/2023/10/03/registerfields-in-django/) +对一个 Django 模型字段的解释,该字段根据键返回类的实例。 + +[Python 类型提示:pyastgrep 案例学习](https://lukeplant.me.uk/blog/posts/python-type-hints-pyastgrep-case-study/) +作者分享了他们在工具 pyastgrep 中向 Python 代码添加类型提示的经验。他们讨论了使用静态类型检查和交互式编程来帮助捕获错误并提高代码可读性的挑战和好处。 + +# 好玩的项目,工具和库 + +[LeptonAI](https://github.com/leptonai/leptonai) +一个用于简化 AI 服务构建的 Pythonic 框架。 + +[RealtimeSTT](https://github.com/KoljaB/RealtimeSTT) +强大、高效、低延迟的语音转文本库,具有先进的语音活动检测、唤醒词激活和即时转录功能。专为诸如语音助手这类实时应用程序而设计。 + +[ziggy-pydust](https://github.com/fulcrum-so/ziggy-pydust) +用于在 Zig 中构建 Python 扩展的工具包。 + +[LLM-scientific-feedback](https://github.com/Weixin-Liang/LLM-scientific-feedback) +大型语言模型能否为研究论文提供有用的反馈?大规模的实证分析。 + +[genai-stack](https://github.com/docker/genai-stack) +这个 GenAI 应用程序栈将让您立即开始构建自己的 GenAI 应用程序。演示应用程序可以作为灵感或起点。 + +[Chrome-GPT](https://github.com/richardyc/Chrome-GPT) +控制桌面版 Chrome 的 AutoGPT 代理。 + +[streaming-llm](https://github.com/mit-han-lab/streaming-llm) +具有注意力接收器的高效流式语言模型。 + +[torch2jax](https://github.com/samuela/torch2jax) +在 JAX 中运行 PyTorch。 + +[swiss_army_llama](https://github.com/Dicklesworthstone/swiss_army_llama) +一种用于语义文本搜索的 FastAPI 服务,使用预先计算的嵌入和高级相似性度量,提供通过 textract 内置对各种文件类型的支持。 + + +# 最新发布 + +[Visual Studio Code 中的 Python —— 2023 年 10 月版本](https://devblogs.microsoft.com/python/python-in-visual-studio-code-october-2023-release/) +此版本包括以下声明: + * Python 调试器扩展更新 + * 弃用对 Python 3.7 的支持 + * Pylint 扩展的更改选项上的 Lint + * Mypy 扩展报告范围和守护进程模式 + * Grace Hopper 会议和开源日参与 + + + +# 近期活动和网络研讨会 + +[ThaiPy #96](https://www.meetup.com/thaipy-bangkok-python-meetup/events/295498832/) +将有以下讲座: +* Python GIL。过去与未来 +* 利用 GPU 加速 100 倍 + + +[PyLadies 2023 年 10 月都柏林聚会](https://www.meetup.com/pyladiesdublin/events/295990212/) +将进行以下演讲: +* 想再次成为一个小朋友吗?年龄永远不是问题! +* 打印您自己的冒险游戏 + + +[PyData 2023 年 10 月南安普顿聚会](https://www.meetup.com/pydata-southampton/events/296057081/) +将进行以下演讲: +* 地理空间数据和处理简介 +* MoleGazer:天文学与皮肤学的结合 + + +[PyData 2023 年 10 月柏林聚会](https://www.meetup.com/pydata-berlin/events/296680621/) +将有一场演讲:利用开源 LLMs 进行生产。 + +[PyData 2023 年 10 月剑桥聚会](https://www.meetup.com/pydata-cambridge-meetup/events/296429788/) +将有一场演讲:使用 AI 技术设计和测试现代桌面棋盘游戏。 + \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_622.md b/Python Weekly/Python_Weekly_Issue_622.md new file mode 100644 index 0000000..401f60d --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_622.md @@ -0,0 +1,107 @@ +原文:[Python Weekly - Issue 622](http://eepurl.com/iB74LY) + +--- + +欢迎来到Python周刊第 622 期。让我们直奔主题。 + +# 新闻 + +[FlaskCon 2023 提案征集现已开放](https://flaskcon.com/2023/) +请在 2023 年 10 月 31 日之前提交您的演讲提案。 + + +# 文章,教程和讲座 + +[函数会让设计模式过时吗?](https://www.youtube.com/watch?v=vzTrLpxPF54) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在本视频中,我们将演示函数并不会让 Python 中的设计模式过时。开发者社区针对此主题进行了广泛的讨论。为了说明这一观点,我们将研究几种常见的设计模式,并提出一种使用函数的替代方法。 + +[在 FastAPI 中构建自定义中间件](https://semaphoreci.com/blog/custom-middleware-fastapi) +在这篇文章中,您将了解如何构建自定义中间件,让你可以通过构建基于函数和基于类的中间件来修改请求和响应对象,以满足自己的需求并处理速率限制,从而使您能够以独特的方式扩展 API 的功能。您还将了解如何编写测试用例以及要遵循的最佳实践。 + +[关于分布式训练和高效微调的一切](https://sumanthrh.com/post/distributed-and-efficient-finetuning) +深入探讨分布式训练和高效微调 - DeepSpeed ZeRO、FSDP、使用多 GPU 和多节点训练的实用指南和陷阱。 + +[Python 3.11 与 Python 3.12 – 性能测试](https://en.lewoniewski.info/2023/python-3-11-vs-python-3-12-performance-testing/) +本文介绍了 Python 3.12 与 Python 3.11 相比的性能测试结果。总共进行了 91 项不同的基准测试,测试使用搭载 AMD Ryzen 7000 系列和第 13 代英特尔酷睿处理器的台式机、笔记本电脑或迷你电脑。 + +[Django 应用程序中无密码身份验证的选项](https://www.honeybadger.io/blog/options-for-passwordless-authentication-in-django/) +在 Django 应用程序中,无密码身份验证因其安全且用户友好的特性,作为基于密码的传统身份验证的的替代方案越来越受欢迎。在本文中,我们将深入研究三种无密码身份验证方法:基于电子邮件的身份验证、OAuth 身份验证和魔术链接身份验证。 + +[我的 eBPF 之旅的开始 - 使用 BBC 的 Kprobe 探险](https://www.kungfudev.com/blog/2023/10/14/the-beginning-of-my-ebpf-journey-kprobe-bcc) +在这篇文章中,作者分享了他们学习 Extended Berkeley Packet Filter (eBPF) 的过程。他们首先解释什么是 eBPF 以及它为何有用。然后,他们描述了如何在 kprobe 和 BPF Compiler Collection (BCC) 的帮助下使用 eBPF 来跟踪内核函数。最后,他们分享了一些他们认为对学习 eBPF 有帮助的资源。 + +[为小团队设置(免费*)协作式 Python 开发环境](https://www.kevin-cole.com/blog/setting-up-a-free-collaborative-python-development-environment-for-a-small-team) +作者介绍了如何使用 GitPod、Github 和 Jupyter Notebook 来设置一个协作式 Python 开发环境。作者还解释了容器化的好处,并提供了如何使用 GitPod、Github 和 Jupyter Notebook 建立协作式 Python 开发环境的分步指南。 + +[实用人工智能:适合初学者的 HuggingFace Transformers和Diffusers](https://www.youtube.com/watch?v=rK02eXm3mfI) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +本视频提供了一个关于 HuggingFace Transformers 和 Diffusers 库的简单概述。针对那些对 AI 或 ML 没有深入了解的人,我们将重点关注实用的实践应用程序。最后,我们设置了一个生成 AI 图像的 Flask 应用程序,演示了如何使用这些工具来创建有用的应用程序。 + +[使用 GPT-4、Python 和 Langchain,构建日语汉字抽认卡应用程序](https://adilmoujahid.com/posts/2023/10/kanji-gpt4/) +GPT-4 正在改变应用程序开发的游戏规则,尤其是在处理数据方面。我们的日语抽认卡应用程序展示了 GPT-4 有多么方便。开发人员可以使用 GPT-4 快速获取所需的信息,而不是手动收集数据。这不仅加快了构建过程,还确保应用程序满是干货。借助 GPT-4 等工具,创建数据丰富的应用程序从未如此简单和高效。 + +[解决 A/B 测试中样本比率不匹配的挑战](https://doordash.engineering/2023/10/17/addressing-the-challenges-of-sample-ratio-mismatch-in-a-b-testing) +这篇文章关于如何解决 A/B 测试中样本比率不匹配的挑战。它讨论了什么是样本比率不匹配,以及为什么它是一个问题。它还详细介绍了 DoorDash 在他们公司中减少样本比率不匹配的一些方法。 + +[Python 陷阱:比较](https://andrewwegner.com/python-gotcha-comparisons.html) +如果您不知道一些常见的陷阱,那么在 Python 中比较两个数值变量可能会产生令人惊讶的结果。这篇文章涵盖了一些常见的问题。 + +[2023 年哥本哈根 Django Day 视频](https://www.youtube.com/playlist?list=PLEpW1LzVyQWgtT_i_IlUmx2FSP2jHcroX) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +第四版哥本哈根 Django Day 的演讲视频现已发布。 + + +# 好玩的项目,工具和库 + +[MemGPT](https://github.com/cpacker/MemGPT) +教 LLMs 无限上下文的内存管理。 + +[SolidGPT](https://github.com/AI-Citizen/SolidGPT) +与您的代码存储库聊天,根据私人项目生成产品需求文档和代码计划。 + +[ZenNotes](https://github.com/rohankishore/ZenNotes) +Windows 记事本替代品,带翻译、TTS 等功能! + +[queryish](https://github.com/wagtail/queryish) +一个库,用于按照 Django 的 QuerySet API 对任意数据源构建查询。 + +[stable-audio-tools](https://github.com/Stability-AI/stable-audio-tools) +用于条件音频生成的生成模型。 + +[ExecuTorch](https://github.com/pytorch/executorch) +端到端解决方案,用于为 PyTorch 模型,跨移动和边缘设备启用设备上 AI。 + +[OpenAgents](https://github.com/xlang-ai/OpenAgents) +一个在野语言代理开放平台 + +[Llemma](https://github.com/EleutherAI/math-lm) +一个数学开放语言模型 + + # 最新发布 + +[Python 3.13.0 alpha 1](https://pythoninsider.blogspot.com/2023/10/python-3130-alpha-1-is-now-available.html) + + + # 近期活动和网络研讨会 + +[BAyPIGgies 2023 年 10 月聚会](https://www.meetup.com/baypiggies/events/296732583/) +将有以下演讲 +- Python、可访问性以及确保 DOM 可访问 (domible) +- WebAssembly、确定性执行以及如何实现撤消 + + +[Virtual:PyLadies 阿姆斯特丹 2023 年 10 月](https://www.meetup.com/pyladiesams/events/296507394/) +在本次研讨会中,您将学习地理空间数据理论的基础知识,涵盖栅格、矢量和相关概念。您还将了解用于地理空间数据的 Python 库,并通过 Jupyter Notebook 练习实际体验如何获得使用卫星图像。 + +[Python Glasgow 2023 年 10 月聚会](https://www.meetup.com/python-glasgow/events/296605211/) +将有以下演讲 +- Python 驱动的智能:探索 AI 和 ML 应用 +- LLM 时代扩展 Python 机器学习工作负载 + + +[PyData 兰卡斯特 2023 年 10 月聚会](https://www.meetup.com/pydata-lancaster/events/296657964/) +将有以下演讲 +- 窥探黑匣子内部:让人工智能模型更易于解释 +- 为什么说你不应仅依赖汇总统计数据 + + +[Hybrid: PyData 芝加哥 2023 年 10 月聚会](https://www.meetup.com/pydatachi/events/296529896/) +有一场演讲,即,FuzzyData:用于测试 Dataframe 工作流系统的可扩展工作负载生成器。 \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_623.md b/Python Weekly/Python_Weekly_Issue_623.md new file mode 100644 index 0000000..ddd6b1b --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_623.md @@ -0,0 +1,99 @@ +原文:[Python Weekly - Issue 623](http://eepurl.com/iCBKtY) + +--- + +欢迎来到Python周刊第 623 期。让我们直奔主题。 +--- + + +# 新闻 + +[PyCon US 2024 提案征集](https://pretalx.com/pyconus2024/) +Pycon US 2024 提案征集现已正式开放,接受演讲、教程、海报和Charlas(一种交流形式)的提议!在2023年12月18日之前提交您的提案。 + + +# 文章,教程和讲座 + +[Pytest 教程 —— 如何测试 Python 代码](https://www.youtube.com/watch?v=cHYq1MRoyI0) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +学习如何使用Pytest,这是Python强大的测试框架。在整个课程中,您将对Pytest的功能,最佳实践以及编写有效测试的细微差别有深入的了解。最后,您将学习如何使用Chatgpt来帮助您更快地编写测试。 + +[使用智能手机录制的语音段,对2型糖尿病进行声学分析和预测](https://www.mcpdigitalhealth.org/article/S2949-7612\(23\)00073-1/fulltext) +通过检查非糖尿病和 T2DM 个人之间的语音记录差异,探讨语音分析作为2型糖尿病(T2DM)患者预筛选或监测工具的潜力 + +[嵌入:它们是什么,以及它们为什么重要](https://simonwillison.net/2023/Oct/23/embeddings/) + +在这篇文章中,Simon Willison探讨了数据分析和机器学习中的嵌入(embeddings)概念,突出了它们在表示复杂数据以进行高效处理方面的作用,并提供了关于它们使用的实际见解。 + +[我们必须聊聊 Flask](https://blog.miguelgrinberg.com/post/we-have-to-talk-about-flask) + +Miguel Grinberg指出,Flask的维护人员经常在新版本的Flask和Werkzeug中引入微不足道的不兼容变化,导致扩展和教程在更新之前会出现问题。现在,[这篇文章也有更新](https://blog.miguelgrinberg.com/post/some-more-to-talk-about-flask)。 + +[lambda 表达式是什么?](https://www.pythonmorsels.com/lambda-expressions/) +了解lambda的表达方式以及如何在Python中使用。 + +[使用 SIMD 加速Cython](https://pythonspeed.com/articles/faster-cython-simd/) +SIMD 是一项CPU功能,让您可以加快数字处理。了解如何与Cython一起使用。 + +[将你的应用插入到 Jupyter 的世界](https://blog.jupyter.org/plug-your-application-into-the-jupyter-world-805e48918801) +Kernel(核心)是Jupyter架构中一个简单但强大的抽象概念。它们封装了语言解释器,并通过标准化接口使其可访问。这是Jupyter出色多才多艺的关键,支持超过100种编程语言。将一个核心嵌入到您的自定义应用程序中,可以无缝地将其暴露给Jupyter生态系统。您不仅可以将JupyterLab附加到您的程序中,以便进行状态检查(就像使用调试器一样),而且还可以真正利用Jupyter生态系统的所有功能来扩展您的应用程序。 + +[如何部署基于 Conda 的 docker 镜像](https://blog.neater-hut.com/how-to-deploy-conda-based-docker-images.html) +学习如何通过三个方法,将基于 Conda 的 Docker 镜像降低到合理的尺寸。 + +[使用 django 和 htmx 的无限滚动](https://fmacedo.com/posts/1-django-htmx-infinite-scroll/) +有关如何使用Django和HTMX实现无限滚动的教程。 + +[如何在 4 分钟内将 Google 表添加为你的 Django 数据库](https://www.youtube.com/watch?v=XXDiqE4t0xA) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在4分钟内添加 Google 表作为您的Django数据库。这是更快的原型和小产品的理想选择。 + + +# 好玩的项目,工具和库 + +[Genv](https://github.com/run-ai/genv) +GPU 环境管理和集群编排 + +[RIP](https://github.com/prefix-dev/rip) +使用 Rust 实现的快速简单的 pip 实现。 + +[LocalPilot](https://github.com/danielgross/localpilot) +在 Macbook 上,一键即可本地使用 GitHub Copilot! + +[autotab](https://github.com/Planetary-Computers/autotab-starter) +为现实世界的任务构建浏览器代理。 + +[GRID](https://github.com/ScaledFoundations/GRID-playground) +通用机器人智能开发(General Robot Intelligence Development,GRID)平台。 + + +[RenderCV](https://github.com/sinaatalay/rendercv) +一个 Python 应用,根据输入的 YAML/JSON 问价,生成 PDF 格式的 CV。 + +[Waymax](https://github.com/waymo-research/waymax) +用于自动驾驶研究的基于 JAX 的模拟器。 + +[DeepSparse](https://github.com/neuralmagic/deepsparse) +用于 CPU 的稀疏性感知深度学习推理运行时。 + +[GenSim](https://github.com/liruiw/GenSim) +通过大型语言模型生成机器人仿真任务(Robotic Simulation Tasks)。 + + +[Voyager](https://spotify.github.io/voyager/) +Voyager是一个用于在内存中的向量集合上执行快速近似最近邻搜索的库。 + +[pypipe](https://github.com/bugen/pypipe) +Python pipe 命令行工具。 + +[dlt](https://github.com/dlt-hub/dlt) +数据加载工具(data load tool,dlt)—— 用于数据加载的开源 Python 库。 + +[Deep-Learning-Ultra](https://github.com/daddydrac/Deep-Learning-Ultra) +开源深度学习容器(Open source Deep Learning Containers,DLCs)是一组用于在 PyTorch、OpenCV(针对GPU进行了编译)、TensorFlow 2(适用于GPU)、PyG 和 NVIDIA RAPIDS 中训练和提供模型的 Docker 镜像。 + +[higgsfield](https://github.com/higgsfield-ai/higgsfield) +容错性强、高度可伸缩的GPU编排系统以及一个机器学习框架,专为训练拥有数十亿至数万亿参数的模型而设计 + + +# 最新发布 + +[Django 5.0 beta 1 发布](https://www.djangoproject.com/weblog/2023/oct/23/django-50-beta-1-released/) \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_624.md b/Python Weekly/Python_Weekly_Issue_624.md new file mode 100644 index 0000000..f405142 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_624.md @@ -0,0 +1,102 @@ +原文:[Python Weekly - Issue 624](http://eepurl.com/iC6EUY) + +--- + +欢迎来到Python周刊第 624 期。让我们直奔主题。 + + +# 文章,教程和讲座 + +[通过 FastAPI 掌握 API 测试:数据库、依赖等等!](https://www.youtube.com/watch?v=9gC3Ot0LoUQ) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +本教程将指导您使用 FastAPI 完成 API 测试,并提供完整的代码示例。使用它作为测试您自己的 API 的模板吧! + + +[使用 Python 将数据分析速度提高 170,000 倍](https://sidsite.com/posts/python-corrset-optimization/) +在这篇文章中,我们将在 Python 中,经历一段分析和迭代加速代码的旅程。 + +[我移植 setup.py 的用户体验](https://gregoryszorc.com/blog/2023/10/30/my-user-experience-porting-off-setup.py/) +本文讨论了将 Python 包从 setup.py 移植到 pyproject.toml 的挑战,以及缺乏明确指导的情况。 + +[算法交易 —— Python 机器学习和量化策略课程](https://www.youtube.com/watch?v=9Y3yaoi9rUQ) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +本课程涵盖三种高级交易策略。首先,它重点关注使用了标准普尔 500 指数数据的无监督学习,其次是纳斯达克股票的 Twitter 情绪投资策略(Twitter Sentiment Investing Strategy),以及使用 GARCH 模型和技术指标识别每日和日内交易信号的日内策略(Intraday Strategy),从而丰富您的金融技能。 + +[使用潜在一致性模型(LCMs),在你的 Mac 上一秒生成图像](https://replicate.com/blog/run-latent-consistency-model-on-mac) +潜在一致性模型 (LCM) 基于稳定扩散(Stable Diffusion),但它们可以更快地生成图像,只需 4 到 8 个步骤即可生成良好的图像(与需要 25 到 50 个步骤才能生成的模型相比)。通过在 M1 或 M2 Mac 上运行 LCM,您可以以每秒一张的速度生成 512x512 图像。 + +[为什么说 Django 管理系统是“丑的”?](https://www.coderedcorp.com/blog/why-is-the-django-admin-ugly/) +本文讨论了为什么 Django 管理界面设计得不够美观。它讨论了 Django 管理系统的历史以及它如此设计的原因。一些重要的点是,Django 管理系统旨在供内部使用,而不是用于构建整个前端。 + +[使用 AI 构建类似 ChatGPT 的应用程序](https://sixfeetup.com/company/news/build-chatgpt-like-apps-with-ai) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +如果您对 AI 和大型语言模型 (LLM) 的实际应用感兴趣,那您会在本演讲和现场演示中发现其价值之处。该演示超越了理论,包括现实世界的示例和最佳实践,包括了一个包含 Python 代码和类似 ChatGPT 的应用程序示例的 GitHub 存储库,这些示例将帮助您启动自己的应用程序。 + + +[不要使用 requirements.txt](https://quanttype.net/posts/2023-10-31-do-not-use-requirements.txt.html) +本文讨论在 Python 项目中使用 requirements.txt 进行包管理的限制。作者建议改用 Poetry(一个包管理器,可以简化依赖管理并提供虚拟环境和文件锁定等附加功能)。 + +[从混乱到凝聚:构建您自己的 Monorepo](https://monadical.com/posts/from-chaos-to-cohesion.html) +使用 GitHub Actions 作为 CI/CD 工具,构建一个简单的 monorepo。 + + +# 好玩的项目,工具和库 + +[SuperDuperDB](https://github.com/SuperDuperDB/superduperdb) +将人工智能带入您最喜欢的数据库!直接与您的数据库和数据进行集成、训练和管理任何 AI 模型和 API。 + +[Esmerald](https://github.com/dymmond/esmerald) +Esmerald 是一个现代、强大、灵活、高性能的 Web 框架,旨在不仅是构建 API,还能够构建从最小到企业级别的完全可扩展应用程序。 + +[mify](https://github.com/mify-io/mify) +一个代码生成工具,帮助您构建云后端服务。 + +[De4py](https://github.com/Fadi002/de4py) +De4py 是一款高级 Python 反混淆器,具有漂亮的 UI 和一组高级功能,使恶意软件分析师和逆向工程师能够对 Python 文件等进行反混淆。 + +[rag-demystified](https://github.com/pchunduri6/rag-demystified) +一个从头开始构建的,由 LLM 驱动的高级 RAG 管道。 + +[m1n1](https://github.com/AsahiLinux/m1n1) +Apple Silicon 的引导加载程序和实验场。 + +[Wonder3D](https://github.com/xxlong0/Wonder3D) +用于从单个图像进行 3D 重建的跨域扩散模型。 + +[LearnHouse](https://github.com/learnhouse/learnhouse) +LearnHouse 是一个开源平台,任何人都可以通过它轻松提供世界一流的教育内容,此外,它提供多种内容类型:动态页面、视频、文档等。 + +[Marcel](https://github.com/geophile/marcel) +一个现代的 shell。 + +[lea](https://github.com/carbonfact/lea) +lea 是 dbt、SQLMesh 和 Google Dataform 等工具的极简替代品。 + +[XAgent](https://github.com/OpenBMB/XAgent) +用于解决复杂任务的自主 LLM 代理。 + +[Raven](https://github.com/CycodeLabs/raven) +CI/CD 安全分析器。 + + +# 最新发布 + +[Django 安全版本已发布:4.2.7, 4.1.13, 和 3.2.23](https://www.djangoproject.com/weblog/2023/nov/01/security-releases/) + + +# 近期活动和网络研讨会 + +[Virtual:PyMNtos Python 演示之夜 #119](https://www.meetup.com/pymntos-twin-cities-python-user-group/events/296436004/) +将有一场演讲,Selenium 和 Python。 + +[PyData 伦敦 2023 年 11 月聚会](https://www.meetup.com/pydata-london-meetup/events/296513974/) +将会有以下演讲: + * 使用 Quix Streams 简化实时 ML 管道 + * 从内到外的 Transformers + * Excel 中的 Python + * 有时,我们听到的音乐和播放列表并不符合我们的心情,人工智能可以帮助解决这个问题吗? + + +[PyData 慕尼黑 2023 年 11 月聚会](https://www.meetup.com/pydata-munchen/events/296950996/) +将会有以下演讲: + * TensorRT LLM Nvidia + * CTranslate2 和 vLLM + * 我今天停止阅读 Twitter 时的 LLM 状态 + diff --git a/Python Weekly/Python_Weekly_Issue_625.md b/Python Weekly/Python_Weekly_Issue_625.md new file mode 100644 index 0000000..4639762 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_625.md @@ -0,0 +1,129 @@ +原文:[Python Weekly - Issue 625](http://eepurl.com/iDALBg) + +--- + +欢迎来到Python周刊第 625 期。让我们直奔主题。 + + +# 文章,教程和讲座 + +[在另一个进程内存中苏醒](https://www.youtube.com/watch?v=0ihChIaN8d0) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在本视频中,我们学习如何通过从头开始构建内存转储器来读取属于其他进程的内存。关键组件之一是 /proc 文件系统:一个内核为内省进程提供的接口。结合 ptrace(一个允许附加并控制另一个进程的系统调用),我们编写了一个程序来自动提取信息(这些信息有可能完全对我们隐藏!) + +[构建 Python 编译器和解释器](https://mathspp.com/blog/tag:bpci) +一个有关在 Python 中从头开始实现 Python 编程语言的系列。本系列的最终目标是探索和尝试实现像 Python 这样的编程语言所需的概念和算法。为此,我们将创建一种具有 Python 功能子集的编程语言,并且在此过程中,我们将使用分词器、解析器、编译器和解释器! + +[数据库的生成列:Django 和 SQLite](https://www.paulox.net/2023/11/07/database-generated-columns-part-1-django-and-sqlite/) +介绍数据库的生成列,使用 SQLite 和 Django 5.0 中添加的新的 GeneratedField 字段。 + +[为什么说在 Windows 上,SciPy 为 Python 3.12 构建是一个小奇迹](https://labs.quansight.org/blog/building-scipy-with-flang) +将 SciPy 迁移到 Meson 意味着在 Windows 上找到不同的 Fortran 编译器,这对于 conda-forge 来说特别棘手。这篇文章讲述了对于 Python 3.12 版本来说,情况是怎样看起来非常严峻的,以及事情如何在关键时刻得到解决的故事。 + +[机器学习软件和 pickles 有什么关系?](https://blog.nelhage.com/post/pickles-and-ml) +本文讨论了作者对在机器学习生态系统中使用 Python 的 pickle 模块的不断发展的看法。它强调了与 pickle 相关的问题、安全问题和脆弱性,深入了解其广泛使用背后的原因以及它在机器学习领域要解决的挑战。 + +[构建一个人工智能工具即时总结书籍](https://levelup.gitconnected.com/build-an-ai-tool-to-summarize-books-instantly-828680c1ceb4) +无需从头到尾阅读即可了解任何书籍的要点。 + +[使用 Python 的 bisect 模块可以做的每一件事](https://martinheinz.dev/blog/106) +了解如何使用“bisect”模块在 Python 中优化搜索并保持数据排序。 + +[构建 Python 数据科学项目的 7 个技巧](https://www.youtube.com/watch?v=xVuqDBCQAYc) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频将介绍简化 Python 数据科学项目结构的 7 个技巧。通过正确的设置和详尽的软件设计,您将能够更有效地修改和增强您的项目。 + +[Python 混淆陷阱](https://checkmarx.com/blog/python-obfuscation-traps/) +在软件开发领域,开源工具和软件包在简化任务和加速开发过程方面发挥着关键作用。然而,随着社区的发展,想要利用社区的不良行为者的数量也在增加。最近的一个例子涉及开发人员成为看似合法的 Python 混淆包的目标,这些混淆包包含恶意代码。 + +[调试 Django 中的 CSRF 失败 / 403 Forbidden 错误](https://www.better-simple.com/django/2023/11/04/debugging-csrf-error-in-production/) +指导性深入理解 Django 源代码,以了解应用程序未通过 CSRF 验证的原因。 + +[Django 5.0 中的新功能](https://fly.io/django-beats/new-goodies-in-django-50/) +本文重点介绍了 Django 5.0 中添加的新功能。 + +[Python 中性能最高的时间戳函数:EXTENDED](https://www.dataroc.ca/blog/most-performant-timestamp-functions-python-2) +第 2 部分介绍了跨 Python 版本和机器类型的不同时间戳函数性能。获取当前时间的最快方法是什么呢? + + +# 好玩的项目,工具和库 + +[LocalAIVoiceChat](https://github.com/KoljaB/LocalAIVoiceChat) +使用基于 Zephyr 7B 模型的自定义语音进行本地 AI 对话。使用 RealtimeSTT 和 fast_whisper 进行转录,使用 RealtimeTTS 和 Coqui XTTS 进行合成。 + +[DeepSeek-Coder](https://github.com/deepseek-ai/DeepSeek-Coder) +让代码自己写代码。 + +[tiger](https://github.com/tigerlab-ai/tiger) +开源 LLM 工具包,用于构建 LLM 应用程序。TigerRAG(嵌入、RAG)、TigerTune(微调)、TigerArmor(AI 安全)。 + +[lm-format-enforcer](https://github.com/noamgat/lm-format-enforcer) +强制执行语言模型的输出格式(JSON 模式、正则表达式等)。 + +[autollm](https://github.com/safevideo/autollm) +在几秒钟内交付基于 RAG 的 LLM Web 应用程序。 + +[lato](https://github.com/pgorecki/lato) +Python 微框架,用于模块化整体和松散耦合的应用程序。 + +[giskard](https://github.com/Giskard-AI/giskard) +ML 模型的测试框架,从表格到 LLMs。 + +[RoboGen](https://github.com/Genesis-Embodied-AI/RoboGen) +一种生成式、自我引导的机器人代理,可以不断地提出和掌握新技能。 + +[error-links](https://pypi.org/project/error-links/) +在发生异常时向 REPL 添加有用的链接。 + +[Hexabyte](https://github.com/thetacom/hexabyte) +一个现代、模块化且强大的 TUI 十六进制编辑器。 + + + # 最新发布 + +[Visual Studio Code 中的 Python – 2023 年 11 月版本](https://devblogs.microsoft.com/python/python-in-visual-studio-code-november-2023-release/) +本版本包括以下声明: + * 对终端中 Shift + Enter 运行的改进 + * 已弃用的内置 linting 和格式化功能 + * Python linting 扩展的改进 + * 重新配置测试输出 + * 虚拟环境停用帮助 + * 宣布 VS Code 中的 Python 的发布视频 + + + +# 近期活动和网络研讨会 + +[旧金山 Python 2023 年 11 月 聚会](https://www.meetup.com/sfpython/events/296321305/) +将会有以下演讲: + * 在 Snowflake 中使用 Python、PyTorch、OpenAI 和 Streamlit 进行图像识别 + * 自动照片修饰 + * 咨询数据库和 Dependabot:以及它们如何应用于 Python + + +[Virtual: PyLadies 柏林 2023 年 11 月 聚会](https://www.meetup.com/pyladies-berlin/events/296907222/) +将会有以下演讲: + * 赋能未来:德国女孩节 + * 开发大规模图像知识共享数据集 + + +[PyLadies 巴黎 2023 年 11 月 聚会](https://www.meetup.com/pyladiesparis/events/297190950/) +将会有以下演讲: + * Django 无停机迁移 + * 调试的科学 + + +[PyData 阿姆斯特丹 2023 年 11 月 聚会](https://www.meetup.com/pydata-nl/events/297111947/) +将会有以下演讲: + * 如何使用机器学习构建出色的风电预测 + * 使用机器学习为电动汽车智能充电 + + +[PyData 布里斯托尔 2023 年 11 月 聚会](https://www.meetup.com/pydata-bristol/events/296142623/) +将会有以下演讲: + * 自然语言处理 —— 从学术理论到商业应用 + * TweetNLP + + +[PyData 蒙特利尔 2023 年 11 月 聚会](https://www.meetup.com/pydata-mtl/events/297096826/) +将会有以下演讲: + * 人类/人工智能超级团队:通过人机循环学习构建协作系统 + * 大型语言模型简介 \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_626.md b/Python Weekly/Python_Weekly_Issue_626.md new file mode 100644 index 0000000..68e1c1b --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_626.md @@ -0,0 +1,111 @@ +原文:[Python Weekly - Issue 626](http://eepurl.com/iD6vfU) + +--- + +欢迎来到Python周刊第 626 期。让我们直奔主题。 + +# 新闻 + +[PyPI 已经完成了首次安全审计](https://blog.pypi.org/posts/2023-11-14-1-pypi-completes-first-security-audit/) +此次审计由网络安全公司 Trail of Bits 负责,重点关注 Warehouse 代码库以及 cabotage 容器编排框架。审计人员发现了29个建议,但没有一个被分类为高危。PyPI 团队已纠正了所有构成重大风险的建议。 + + +# 文章,教程和讲座 + +[什么是 Monad?](https://www.youtube.com/watch?v=Q0aVbqim5pE) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +Monad 是函数式编程语言(如Haskell)中的一个众所周知的概念,但它们在其他情境中是否同样有用呢?请继续关注,到本视频结束时,您将了解什么是 Monad。 + + +[让我们一起创造一个 Python 调试器吧](https://mostlynerdless.de/blog/2023/09/20/lets-create-a-python-debugger-together-part-1/) +您是否曾想过调试器是如何工作的?设置断点并稍后命中它时会发生什么呢?调试器是我们作为开发人员在日常工作中经常使用的工具,但很少有人知道它们实际上是如何实现的。以下是有关从零开始编写 Python 调试器系列,包含四部分。 + +[快速浏览目标驱动的代码生成](https://bernsteinbear.com/blog/ddcg/) +想象一下:你坐在那里,正在写一个编译器,突然间你不得不生成汇编。你有一些中间表示(IR),但现在你必须将虚拟寄存器转换为机器寄存器。这就是所谓的寄存器分配(register allocation)。寄存器分配很棘手。它也很慢。即使像线性扫描这样非常快的寄存器分配器也可能占据大部分编译时间。所以让我们跳过它。让我们用 Python 写一个愚蠢的编译器,看看我们是否可以在不进行完全寄存器分配的情况下改进生成的代码。 + +[在Python软件包索引中查询每个发布的每一个文件](https://sethmlarson.dev/security-developer-in-residence-weekly-report-18) +本文介绍了查询 Python 软件包信息数据集的问题。它讨论了如何下载数据集以及其中包含了什么信息。该数据集可用于回答有关 Python 软件包趋势的问题。例如,它可用于跟踪新的打包元数据标准的采用情况。 + +[使用 django-watson 为 Django 应用添加全文搜索](https://idiomaticprogrammers.com/post/django-watson-full-text-search-guide/) +学习如何通过 Django-Watson 在 Django 应用中添加全文搜索,深入了解 Postgres 的奥秘并提升搜索功能。 + +[深入研究 PyPI 软件包名称占用](https://blog.orsinium.dev/posts/py/pypi-squatting/) +本文讨论了 PyPI 软件包名称占用的问题,以及攻击者可以如何利用它来分发恶意代码。 + +[解混淆 World of Warships 的 Python 脚本](https://landaire.net/world-of-warships-deobfuscation/) +对World of Warships 如何混淆其游戏脚本以及如何在很大程度上对其进行解混淆的深入分析。 + +[Python 中基于属性的测试](https://www.se-radio.net/2023/11/se-radio-589-zac-hatfield-dodds-on-property-based-testing-in-python/) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/9a9a57d0-eb4b-47f8-8af4-55ba50e8c350.png) +Anthropic 的保障团队负责人 Zac Hatfield-Dodds 与主持人 Gregory M. Kapfhammer 讨论了基于属性的测试技术,以及如何在名为 Hypothesis 的开源工具中使用它们。他们讨论了如何为 Python 函数定义属性并在 Hypothesis 中实现一个测试用例。他们还探讨了 Hypothesis 中的一些高级功能(可以自动生成测试用例并执行模糊测试活动)。 + + +# 好玩的项目,工具和库 + +[MonkeyPatch](https://github.com/monkeypatch/monkeypatch.py) +构建可扩展的 LLM 驱动应用程序的最简单方法,随着时间推移变得更便宜和更快。 + +[Movis](https://github.com/rezoo/movis) +用代码的方式编辑视频 + +[dpoint](https://github.com/Jcparkyn/dpoint) +使用相机跟踪和惯性测量的开源数字触控笔。 + +[narrator](https://github.com/cbh123/narrator) +大卫·艾滕伯勒为您叙述生活。 + +[mirror](https://github.com/cocktailpeanut/mirror) +在您的笔记本电脑上的可黑客化 AI 驱动镜子。 + +[filequery](https://github.com/MarkyMan4/filequery) +使用 SQL 查询 CSV、JSON 和 Parquet 文件。 + +[bulk_transcribe_youtube_videos_from_playlist](https://github.com/Dicklesworthstone/bulk_transcribe_youtube_videos_from_playlist) +使用 Whisper,轻松将整个 YouTube 播放列表转换为高质量的脚本。 + +[vimGPT](https://github.com/ishan0102/vimGPT) +使用 GPT-4V 和 Vimium 浏览网络。 + +[multi-object-tracking-in-python](https://github.com/kharitonov-ivan/multi-object-tracking-in-python) +在 Python 中实现多目标跟踪算法,包括 PMBM(泊松多伯努利混合滤波器)。 + + +# 近期活动和网络研讨会 + +[PyLadies Dublin Meetup 2023 年 11 月](https://www.meetup.com/pyladiesdublin/events/296639107/) +将有以下演讲: +* Pinkie Pacts - 基于消费者的合同测试 +* 关于再保险风险建模的介绍,使用 Python + +[PyLadies London Meetup 2023 年 11 月](https://www.meetup.com/pyladieslondon/events/297095588/) +将有以下演讲: +* 使用 ClinicalTrials.gov API 解锁有关妇女健康的见解 +* 使用 Neo4j Vector Search 将患者匹配到临床试验 + + +[Python Milano Meetup 2023 年 11 月](https://www.meetup.com/python-milano/events/297364921/) +将有以下演讲: +* Kubernetes Operators:用 Pythonic 的方式 +* 边缘设备上的视觉体系结构 + + +[PyData Prague Meetup 2023 年 11 月](https://www.meetup.com/pydata-prague/events/297072175/) +将有以下演讲: +* 成为 Streamlit 的数据叙述者! +* 检索增强生成(RAG)在实践中的应用 + + +[PyData Southampton Meetup 2023 年 11 月](https://www.meetup.com/pydata-southampton/events/296812566/) +将有以下演讲: +* 谨上您的真诚,Streamlit +* 车队监控:使用 Django 和 Plotly Dash 构建可扩展的云应用程序 + + +[PyData Lisbon Meetup 2023 年 11 月](https://www.meetup.com/pydata-lisbon/events/297070615/) +将有以下演讲: +* LLM 系统的趋势和挑战 +* AI 启示还是 AI 革命?- 产品经理作为 AI 守护者的角色 + + +[PyData Stockholm Meetup 2023 年 11 月](https://www.meetup.com/pydatastockholm/events/297112148/) +将有以下演讲: +* FastAPI 入门:ML 的技巧和窍门 +* 谁需要 ChatGPT?使用 Hugging Face 和 Kedro 打造坚固的 AI 管道 diff --git a/Python Weekly/Python_Weekly_Issue_627.md b/Python Weekly/Python_Weekly_Issue_627.md new file mode 100644 index 0000000..7df31d9 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_627.md @@ -0,0 +1,127 @@ +原文:[Python Weekly - Issue 627](http://eepurl.com/iEB-HQ) + +--- + +欢迎来到Python周刊第 627 期。让我们直奔主题。 + + +# 文章,教程和讲座 + +[为 CPython 开发的 JIT 编译器](https://www.youtube.com/watch?v=HxSHIpEQRjs) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +Brandt Bucher 讨论了为 CPython 开发的即时(Just-In-Time,JIT)编译器。演讲深入探讨了专门为 CPython(默认的Python解释器)实现 JIT 编译器的挑战和复杂性。 + +[给初学者的生成式 AI 教程](https://microsoft.github.io/generative-ai-for-beginners/) +一门包含 12 课的课程,教授构建生成式 AI 应用程序所需的一切知识。 + +[大规模编写和linting Python](https://engineering.fb.com/2023/11/21/production-engineering/writing-linting-python-at-scale-meta/) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/9a9a57d0-eb4b-47f8-8af4-55ba50e8c350.png) +在 Meta 公司,Python 在 Instagram 的后端中起着关键作用,为 Python 3.12 做出贡献,并驱动着诸如配置系统和 AI 工作等关键方面。在 Meta Tech Podcast中,Pascal Hartig 和 Amethyst Reese 深入探讨了 Python 基础团队所做的努力,开源的 Fixit 2 linter 框架,以及关于在 Meta 所担任的生产工程师角色的见解。 + +[是时候改变了:datetime.utcnow() 现在已弃用](https://blog.miguelgrinberg.com/post/it-s-time-for-a-change-datetime-utcnow-is-now-deprecated) +本文介绍了关于这些函数被弃用的原因的更多信息,以及替换它们的方法。 + +[通过 AWS 发布 280 亿分子嵌入](https://ashvardanian.com/posts/usearch-molecules/) +宣布了一个涉及收集、指纹识别和索引 70 亿种小分子(具有各种结构嵌入,例如 MACCS、PubChem、ECFP4 和 FCFP4)的项目的完成。该数据集使用 Unum 的 USearch 针对分子搜索进行了优化,现在可以通过 AWS Open Data 在全球范围内免费访问,它还通过 GitHub 提供了全面的数据表和可视化脚本。 + +[Python 全局解释器锁提供的不断变化的“保证”](https://stefan-marr.de/2023/11/python-global-interpreter-lock/) +本文探讨了 CPython 全局解释器锁 (Global Interpreter Lock,GIL) 的实现细节,以及它们在 Python 3.9 和当前开发分支(将成为 Python 3.13)之间的变化。 + +[让我们使用 LLM Embeddings、Django 和 pgvector 编写一个 AI 搜索引擎](https://www.youtube.com/watch?v=OPy4dLHdZng) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +大型语言模型 (Large Language Model,LLM) 可用于业务应用程序,例如内容匹配和职位搜索。William Huster 演示了如何构建利用 LLM 进行职位搜索的原型应用程序。 + +[两种线程池,以及为什么需要这两种](https://pythonspeed.com/articles/two-thread-pools/) +线程池应该有多大?这取决于您的用例。 + +[Python 3.12 范型类型解释](https://www.youtube.com/watch?v=q6ujWWaRdbA) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频探讨了 Python 3.12 中的泛型类型的工作原理,以及它的优势(相对于仅使用 Any 类型)。 + +[使用 Polars 在云端处理数百 GB 的数据](https://blog.coiled.io/blog/coiled-functions-polars.html) +由于内存和网络限制,本地计算机可能难以处理大型数据集。Coiled Functions 提供了一种基于云的解决方案,可以高效且经济高效地处理如此广泛的数据集,克服本地硬件对复杂数据处理任务的限制。融入像 Polars 这样的库可以进一步增强这种方法,利用优化的计算功能,从而更快、更高效地处理数据。在这篇文章中,我们将使用 Coiled Functions,在带有 Polars 的单个云计算机上处​​理 150 GB 大小的 Uber-Lyft 数据集。 + +[Python 应用程序中的错误类别](https://threeofwands.com/the-types-of-errors-in-python-apps/) +编写 Python 程序时,错误是不可避免的。然而,我们可以管理我们所产生的错误类型。让我们探索一个简单的模型,它将这些错误按照从最好到最差进行分类,然后讨论谨慎使用工具可以如何提高软件质量。 + +[GPU 上的 Pandas Dataframes(使用或不使用 CuDF)](https://www.youtube.com/watch?v=OnYGtKQT-rU) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +使用 CuDF 的 Pandas 加速器的概述和一些快速示例,以及与普通 Pandas 相比,使用它进行数据分析要快多少。 + +[使用 PyTorch 构建一个神经网络](https://haydenjames.io/building-a-neural-network-with-pytorch/) +构建第一个神经网络似乎是一项艰巨的任务,但像 PyTorch 这样的深度学习框架使得这项任务比以往任何时候都更容易完成。本文介绍了如何使用 PyTorch 构建神经网络。 + +[Python Flask 应用程序中的 GitHub OAuth](https://supabase.com/blog/oauth2-login-python-flask-apps) +有关在 Python 应用程序中构建使用 Github 进行登录的分步指南。 + +[如何使用 Django 和 Stripe 创建订阅 SaaS 应用程序](https://www.saaspegasus.com/guides/django-stripe-integrate/) +使用基于 Python 的 Django Web 框架和 Stripe 支付处理器创建订阅 SaaS 业务的所有技术细节。 + +[四种优化](https://tratt.net/laurie/blog/2023/four_kinds_of_optimisation.html) +本文讨论了四种优化程序的方法:使用更好的算法、使用更好的数据结构、使用较低级别的系统,或接受不太精确的解决方案。 + +[使用 Python 通过 PostgREST API 插入数据](https://www.dataroc.ca/blog/inserting-data-via-the-postgrest-api-using-python) + +[CPython 软件物料清单提案](https://sethmlarson.dev/security-developer-in-residence-weekly-report-19) + +[有多少 Python 核心开发人员使用类型注释?](https://blog.orsinium.dev/posts/py/core-devs-typing/) + + +# 好玩的项目,工具和库 + +[LoRAX](https://github.com/predibase/lorax) +在生产中为 100 个经过微调的 LLM 提供服务,成本为 1. + +[AIConfig](https://github.com/lastmile-ai/aiconfig) +配置驱动、源代码控制友好的 AI 应用程序开发。 + +[Frigate](https://github.com/blakeblackshear/frigate) +Frigate 是一款围绕实时 AI 对象检测构建的开源 NVR。所有处理都是在您自己的硬件上本地执行的,并且您的相机馈送永远不会离开您的家。 + +[PyNest](https://github.com/PythonNest/PyNest) +PyNest 是一个构建在 FastAPI 之上的 Python 框架,遵循 NestJS 的模块化架构。 + +[ai-exploits](https://github.com/protectai/ai-exploits) +真实世界 AI/ML 漏洞利用的集合,用于负责任地披露的漏洞。 + +[pytest-patterns](https://github.com/flyingcircusio/pytest-patterns) +pytest-patterns 是 pytest 的插件,提供专门针对测试优化的模式匹配引擎。 + +[Google-Colab-Selenium](https://github.com/jpjacobpadilla/Google-Colab-Selenium) +在 Google Colab 笔记本中使用 Selenium 的最佳方式! + +[stateless](https://github.com/suned/stateless) +Python 的静态类型、纯函数效果。 + +[sqlalchemy_data_model_visualizer](https://github.com/Dicklesworthstone/sqlalchemy_data_model_visualizer) +自动将您的 SQLalchemy 数据模型转换为漂亮的 SVG 图 + +[StyleTTS 2](https://github.com/yl4579/StyleTTS2) +通过风格扩散(Style Diffusion)和大型语音语言模型的对抗性训练实现人类水平的文本到语音转换 + +[screenshot-to-code](https://github.com/abi/screenshot-to-code) +放入屏幕截图并将其转换为干净的 HTML/ Tailwind/JS 代码。 + +[NeumAI](https://github.com/NeumTry/NeumAI) +Neum AI 是一个一流的框架,用于管理大规模矢量嵌入的创建和同步。 + + +# 最新发布 + +[Python 3.13.0 alpha 2 现已推出](https://pythoninsider.blogspot.com/2023/11/python-3130-alpha-2-is-now-available.html) + +[Django 5.0 候选版本 1 已发布](https://www.djangoproject.com/weblog/2023/nov/20/django-50-rc1/) + + +# 近期活动和网络研讨会 + +[Virtual:PyMunich Meetup 2023 年 11 月](https://www.meetup.com/pymunich/events/296949399/) +将有以下演讲: +* Python 元编程简介 +* 数据科学家的知识产权 +* 生产中利用开源 LLM + +[PyBerlin 42](https://www.meetup.com/pyberlin/events/296945261/) +将有以下演讲: +* 浏览器中的 CPU:WebAssembly 揭秘 +* 敏捷交付的四个关键问题 +* 将 LLM 纳入实际的 NLP 工作流程中 +* Web 黑客:通过单个 Python 漏洞接管服务器 + +[PyData Copenhagen Meetup 2023 年 11 月](https://www.meetup.com/pydata-copenhagen/events/297375748/) +将有一场演讲,加速 ML 原型设计:利用 HiPlot 和 Patsy 以思维的速度进行特征工程。 diff --git a/Python Weekly/Python_Weekly_Issue_628.md b/Python Weekly/Python_Weekly_Issue_628.md new file mode 100644 index 0000000..d8f9635 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_628.md @@ -0,0 +1,109 @@ +原文:[Python Weekly - Issue 628](http://eepurl.com/iE8zjE) + +--- + +欢迎来到Python周刊第 628 期。**Y Combinator** 公司中的其中一家正在寻找一名具有 6 年以上经验、在 ETL、图形 DB 和基于 Python 的 REST 后端方面拥有专业知识,并且准备为 B2B 销售技术构建尖端解决方案的**创始工程师**。这个角色在美国是远程工作的。This role is remote in the US. 我很了解这家公司的创始人。如果您拥有必要的技能和经验并且有兴趣,请向我发送您的简历。 + + +# 文章,教程和讲座 + +[大语言模型简介](https://www.youtube.com/watch?v=zjkBMFhNj_g) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +Andrej Karpathy 的大型语言模型简介讲座涵盖了 ChatGPT、Claude 和 Bard 等系统背后的核心技术组件。它们是什么、它们的发展方向、与当今操作系统的比较和类比,以及这种新计算范式的一些与安全相关的挑战。 + +[Rust std fs 比 Python 慢!?不,是硬件的锅!](https://xuanwo.io/2023/04-rust-std-fs-slower-than-python/) +加入我们,踏上一段富有启发性的旅程,从 opendal 的 op.read() 开始,走向惊人,作者沿途会分享他们的经验教训。 + +[使用 Numba 解锁 pandas.DataFrame.apply 中的 C 级性能](https://labs.quansight.org/blog/unlocking-c-level-performance-in-df-apply) +快速概述 DataFrame.apply 中的新的 Numba 引擎。 + +[Spinning Up in Deep RL](https://spinningup.openai.com/en/latest/) +由 OpenAI 制作的教育资源,让您可以更轻松地了解深度强化学习(deep RL)。 + +[Python 作为值的错误:比较来自 Go 和 Rust 的有用模式](https://www.inngest.com/blog/python-errors-as-values) +更安全的错误处理,受 Go 和 Rust 启发。 + +[在 Python 中构建一个小型 REPL](https://bernsteinbear.com/blog/simple-python-repl/) +在我之前用 Python 编写的许多解释器/编译器项目中,我手动编写了一个 REPL(read-eval-print-loop,读取-评估-打印-循环)。事实证明,Python 附带了一堆完备的功能,以至于它们显得完全没有必要——你免费就能获得很多好东西。让我们看看如何使用它们,就从在项目中嵌入普通的 Python REPL 开始。 + +[在 vanilla Django 中构建 Bootstrap 风格的表单](https://smithdc.uk/blog/2023/bootstrap_form_in_vanilla_django) +在这篇文章中,David Smith 探索了在 vanilla Django 中创建 Bootstrap 风格的表单而不依赖第三方包的方法。他讨论了自定义表单小部件、添加 CSS 类以及创建自定义字段模板。 + +[使用 Sub Interpreter 运行 Python 并行应用](https://tonybaloney.github.io/posts/sub-interpreter-web-workers.html) +Python 3.12 引入了一个新的“sub interpreter” API,这是一种不同的 Python 并行执行模型,它在多处理的真正并行性之间提供了很好的折衷,但启动时间更快。这篇文章将解释什么是sub interpreter为什么它对于 Python 中的并行代码执行很重要、以及它与其他方法之间的比较。 + +[CPython 对象系统内部结构:了解 PyObject 的角色](https://codeconfessions.substack.com/p/cpython-object-system-internals-understanding) +了解 CPython 中是如何实现对象的,以及 CPython 如何使用结构嵌入模拟 C 中的继承和多态性。 + +[Robot Dad](https://blog.untrod.com/2023/11/robot-dad.html) +这是一篇关于一位父亲的文章,他创建了一个名为 Robot Dad 的聊天机器人来回答他儿子的问题。这个聊天机器人能够通过 Google 搜索来访问和处理来自现实世界的信息。Robot Dad 还可以用来翻译语言。 + +[Python 中简单的 WebSocket 基准测试](https://lemire.me/blog/2023/11/28/a-simple-websocket-benchmark-in-python) + +[Python,Asyncio 和 Footguns](https://ryanc118.medium.com/python-asyncio-and-footguns-8ebdb4409122) + +[LMQL —— 用于语言模型的 SQL](https://towardsdatascience.com/lmql-sql-for-language-models-d7486d88c541) + + + # 好玩的项目,工具和库 + +[rags](https://github.com/run-llama/rags) +在您的数据上构建 ChatGPT,全部使用自然语言。 + +[easylkb](https://github.com/deepseagirl/easylkb) +易用的 Linux Kernel Builder。 + +[kanban-python](https://github.com/Zaloog/kanban-python) +用 Python 编写的终端看板应用,可用来提高您的工作效率。 + +[ProAgent](https://github.com/OpenBMB/ProAgent) +从机器人流程自动化到代理流程自动化。 + +[autometrics-py](https://github.com/autometrics-dev/autometrics-py) +轻松将指标添加到您的代码中,这些指标实际上可以帮助您发现和调试生产中的问题。基于 Prometheus 和 OpenTelemetry 构建。 + +[Subtitle](https://github.com/innovatorved/subtitle) +开源字幕生成,用于无缝内容翻译。 + +[Breezy](https://github.com/breezy-team/breezy) +具有用户友好界面的分布式版本控制系统。 + +[Flask-Muck](https://github.com/dtiesling/flask-muck) +Flask-Muck 是一个功能齐全的框架,用于在 Flask/SqlAlchemy 应用程序堆栈中,自动生成带有创建、读取、更新和删除 (CRUD) 端点的 RESTful API。 + +[self-operating-computer](https://github.com/OthersideAI/self-operating-computer) +使多模式模型能够操作计算机的框架。 + +[apple-home-key-reader](https://github.com/kormax/apple-home-key-reader) +该项目提供了使用 Python 构建 Apple Home Key Reader 的演示。 + +[sysaidmin](https://github.com/skorokithakis/sysaidmin/) +Sysaidmin 是为你的机器准备的,由 GPT 提供支持的系统管理员。你可以要求它解决问题,它会在您的系统上运行命令(经过您的许可)来调试正在发生的情况。 + +[Meditron](https://github.com/epfLLM/meditron) +Meditron 是一套开源医疗大语言模型(LLM)。 + +[pip.wtf](https://pip.wtf/) +小型 Python 脚本的内联依赖项。 + + + # 近期活动和网络研讨会 + +[PyData Cambridge Meetup 2023 年 12 月](https://www.meetup.com/pydata-cambridge-meetup/events/297337394/) +将会有一场演讲:使用 Polars 进行网络安全中的实用检测工程。 + +[PyData Amsterdam Meetup 2023 年 12 月](https://www.meetup.com/pydata-nl/events/297098652/) +将有以下演讲: + * 智能银行:释放 AI 的潜力 + * 支付处理中的多模型优化 + * 金融科技的模型选择:优缺点 + +[PyData London Meetup 2023 年 12 月](https://www.meetup.com/pydata-london-meetup/events/297585435/) +将举行以下会议: + * Python 依赖管理器大对决 + * 为什么我切换到 Windows + + +[VilniusPY #24](https://www.meetup.com/vilniuspy/events/297507169/) +将有以下演讲: + * 重新认证:如何成为一名成功的入门级开发人员 + * 将 Python 项目迁移到 K8s diff --git a/Python Weekly/Python_Weekly_Issue_629.md b/Python Weekly/Python_Weekly_Issue_629.md new file mode 100644 index 0000000..68a3feb --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_629.md @@ -0,0 +1,125 @@ +原文:[Python Weekly - Issue 629](http://eepurl.com/iFDrxQ) + +--- + +欢迎来到Python周刊第 629 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[深入探讨 Python 中的状态设计模式](https://www.youtube.com/watch?v=5OzLrbk82zY) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在本视频中国呢,我将探讨 Python 中的状态设计模式,这是管理面向对象编程中状态更改的游戏颠覆者。 + +[Django 5.0 的新功能!](https://www.youtube.com/watch?v=lPl5Q5gv9G8) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +你有没有在倒计时呢?不是圣诞节...而是新的 Django 版本!Django 5.0 发布了!让我们一起揭开我们最喜欢的 Python Web 框架带给我们的新礼物。 + +[在 Pandas 世界中使用 Polars](https://pythonspeed.com/articles/polars-pandas-interopability/) +Pandas 拥有比 Polars 更多的第三方集成。了解如何将这些库与 Polars 的 dataframe 一起使用吧。 + +[将现有 Python 项目切换到 Ruff](https://www.youtube.com/watch?v=ETG5azrc4F4) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在最近的构建 SaaS 流中,我们从基于 flake8、Black、isort 和 bandit 的技术栈完全切换到使用单一工具 Ruff。观看经验丰富的 Pythonista 是如何使用多种选项,并完全切换到使用这个强大的工具的。 + +[无类型 Python:曾经的 Python](https://lucumr.pocoo.org/2023/12/1/the-python-that-was/) +思考多年来 Python 上所发生的变化,特别是类型。 + +[比 Meta 的 FAISS 快 10 倍](https://www.unum.cloud/blog/2023-11-07-scaling-vector-search-with-intel) +在英特尔的 Sapphire Rapids CPU 上,使用 Gcore 扩展 USearch Vector Search 引擎。 + +[使用 PyTorch II 加速生成式 AI:GPT,快](https://pytorch.org/blog/accelerating-generative-ai-2/) +本文是多系列博客的第二部分,重点介绍如何使用纯原生 PyTorch 加速生成式 AI 模型。我们很高兴与大家分享新发布的 PyTorch 性能特性以及实用示例,以了解我们可以将 PyTorch 原生性能提升到什么程度。在第一部分中,我们展示了如何仅使用纯原生 PyTorch 将 Segment Anything 速度提高超过 8 倍。在这篇文章中,我们将重点关注 LLM 优化。 + +[MLOps 课程 – 构建机器学习生产级项目](https://www.youtube.com/watch?v=-dJPoLm_gtE) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +MLOps 是机器学习操作(Machine Learning Operations)的缩写,指将 DevOps 原则应用于机器学习的实践。本 MLOps 课程将指导您完成端到端 MLOps 项目,涵盖从数据摄取到部署的所有内容,使用 ZenML、MLflow 和各种 MLOps 库等最先进的工具。 + +[Visual Studio Code 中的 Python Linting – 提示和 Linting 视频系列](https://devblogs.microsoft.com/python/python-linting-video/) +编写代码最重要的部分之一是确保代码可读。干净的代码有很多积极的下游效应,包括易于维护和添加功能、调试微妙的编程错误或查找未初始化的变量。有些人称此为代码卫生。VS Code 支持 linter 扩展,使您能够更快地开发、生成更清晰的代码并根据您的设置进行调整。 + + +# 好玩的项目,工具和库 + +[Dropbase](https://github.com/DropbaseHQ/dropbase) +Dropbase 可帮助您使用 Python 构建内部 Web 应用程序。Dropbase 自托管 Worker 可以与您自己的基础设施中的数据安全地进行交互。 + +[MLX](https://github.com/ml-explore/mlx) +MLX 是 Apple 芯片上用于机器学习的阵列框架,由 Apple 机器学习研究团队提供。 + +[unsloth](https://github.com/unslothai/unsloth) +速度提高 5 倍,内存减少 50% 的 LLM 微调。 + +[Gymbo](https://github.com/Koukyosyumei/Gymbo) +从头开始实现的基于梯度的符号执行引擎。 + +[marker](https://github.com/VikParuchuri/marker) +快速、高精度地将 PDF 转换为 Markdown + +[gpt-fast](https://github.com/pytorch-labs/gpt-fast) +简单高效的 p​​ytorch 原生转换器文本生成。 + +[TaskWeaver](https://github.com/microsoft/TaskWeaver) +一个代码优先的代理框架,用于无缝规划和执行数据分析任务。 + +[Amphion](https://github.com/open-mmlab/Amphion) +开源音频、音乐和语音生成工具包。 + +[akarsu](https://github.com/furkanonder/akarsu/) +基于 PEP 669 的新一代分析器。 + +[Skyfield](https://rhodesmill.org/skyfield/) +用 Python 实现的优雅天文学。 + +[Dobb*E](https://github.com/notmahi/dobb-e/) +一个用于学习家政机器人操作的开源通用框架 + +[GeoDream](https://github.com/baaivision/GeoDream) +解开 2D 和几何先验,以实现高保真和一致的 3D 生成。 + +[mlx-examples](https://github.com/ml-explore/mlx-examples) +MLX 框架中的示例。 + +[great-tables](https://github.com/posit-dev/great-tables) +使用 Python 轻松生成信息丰富且达到出版质量的表格。 + +[DataStack](https://github.com/data-stack-hub/DataStack) +Datastack 是一个开源框架,让您能够仅使用 Python 就可以轻松构建实时 Web 应用程序、内部工具、仪表板、周末项目、数据输入表单或原型,无需前端经验 + +[Canopy](https://github.com/pinecone-io/canopy) +Canopy 是一个构建在 Pinecone 矢量数据库之上的开源检索增强生成 (RAG) 框架和上下文引擎。Canopy 使您能够使用 RAG 快速轻松地试验和构建应用程序。通过几个简单的命令即可开始与文档或文本数据聊天。 + +[Above](https://github.com/wearecaster/Above) +隐形网络协议嗅探器。 + + +# 最新发布 + +[Django 5.0 已发布](https://www.djangoproject.com/weblog/2023/dec/04/django-50-released/) +发行说明详细介绍了大量令人兴奋的新功能,其中一些亮点是: + * 数据库计算的默认值:允许将数据库计算的默认值定义为模型字段。 + * 延续 Django ORM 扩展的趋势,生成的模型字段允许创建数据库生成的列。 + * 字段组的概念被添加到模板系统中,以简化表单字段呈现。 + + + # 近期活动和网络研讨会 + +[Django London 2023 年 12 月聚会](https://www.meetup.com/djangolondon/events/297502880/) +将有一场演讲,支持初级开发人员:我的旅程所得。 + +[ClePy 2023 年 12 月](https://www.meetup.com/cleveland-area-python-interest-group/events/296720145/) +将有一场演讲:使用 FastAPI 和 Pydantic 构建 GPT Action。 + +[Python Milano 2023 年 12 月聚会](https://www.meetup.com/python-milano/events/297758655/) +将有以下演讲 + * Streamlit:献给所有人的示例驱动学习 + * 使用 Streamlit 快速交付 MVP + + +[PyData Stockholm 2023 年 12 月聚会](https://www.meetup.com/pydatastockholm/events/297677610/) +将有以下演讲 + * DuckDB:转变数据管理和分析 + * 即时 MLOps:使用 DuckDB 和 ArrowFlight 来优化特征存储 + + +[PyData Lausanne 2023 年 12 月聚会](https://www.meetup.com/pydata-lausanne/events/297505348/) +将有以下演讲 + * Python 的 API 和数据模拟 + * Model-X 仿制品 + + diff --git a/Python Weekly/Python_Weekly_Issue_630.md b/Python Weekly/Python_Weekly_Issue_630.md new file mode 100644 index 0000000..49fa38f --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_630.md @@ -0,0 +1,81 @@ +原文:[Python Weekly - Issue 630](http://eepurl.com/iF-TCw) + +--- + +欢迎来到Python周刊第 630 期。让我们直奔主题。 + + +# 文章,教程和讲座 + +[Vector Search RAG 教程 —— 通过高级搜索,将您的数据与 LLMs 结合起来](https://www.youtube.com/watch?v=JEBDfGqrAUA) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +了解如何使用矢量搜索(Vector Search)和嵌入轻松地将数据与 GPT-4 等大型语言模型相结合。您将首先学习概念,然后创建三个项目。 + +[在运行时注释](https://blog.glyph.im/2023/12/annotated-at-runtime.html) +PEP 593 对于如何实际使用 Annotated 参数这一点有些含糊其辞;这是我的建议。 + +[pytest 守护进程:10 倍本地测试迭代速度](https://discord.com/blog/pytest-daemon-10x-local-test-iteration-speed) +在 Discord,他们的 Python 测试套件本地测试运行缓慢,每次测试需要 13 秒。他们构建了一个 pytest 守护进程,将本地测试迭代速度提高了 10 倍,显着缩短了开发时间。该解决方案涉及将繁重的工作卸载到后台进程并缓存结果,绕过缓慢的导入和固定装置。 + +[在 Python 中执行 a + b 需要多少行 C 代码?](https://codeconfessions.substack.com/p/cpython-dynamic-dispatch-internals) +了解 CPython 中动态调度实现的机制。 + +[为什么使用 TYPE_CHECKING?](https://vickiboykis.com/2023/12/11/why-if-type_checking/) +本文讨论了 Python 中条件导入的使用,特别是 if TYPE_CHECKING 模式,以解决 mypy 等工具强制执行的类型检查和运行时类型检查的差异。它探讨了在处理存在大量相互依赖并可能导致循环依赖的自定义类时,是否需要此模式。 + +[对扇出模式(Fanout Pattern)的解释](https://www.better-simple.com/django/2023/12/06/fanout-pattern-explained) +本文讨论了扇出模式在 Celery 任务上下文中的使用,其中单个任务可以替换为数量可变的其他任务。它提供了一个关于扇出模式的实际示例,及其在处理复杂任务签名中的应用,强调了它在 Celery 框架内的任务设计和管理中的强大功能。通过代码示例说明了扇出模式,展示了其处理顺序和并行任务执行的能力,提供了对于其任务编排和工作负载分配的有效性的一些见解。 + +[Django:使用 nh3 清理传入的 HTML 片段](https://adamj.eu/tech/2023/12/13/django-sanitize-incoming-html-nh3/) +让我们看看如何在 Django 表单中使用 nh3 进行 HTML 清理。您可以将此方法应用于其他情况,例如在 DRF 序列化器中。 + +[现实中的 match/case](https://nedbatchelder.com/blog/202312/realworld_matchcase.html) +Python 3.10 引入了结构模式匹配,称为 match/case,它允许匹配数据结构中的模式。本文提供了一个使用匹配/大小写来简化对从 GitHub 机器人接收的复杂 JSON 有效负载的检查的真实示例,展示了其在处理深度嵌套数据结构方面的实际应用。作者强调了与传统的分离有效负载的方法相比,match/case 如何使任务变得更加简单 + + +# 好玩的项目,工具和库 + +[coffee](https://github.com/Coframe/coffee) +使用 AI 直接在您自己的 IDE 上构建和迭代您的 UI,速度提高 10 倍。 + +[µHTTP](https://github.com/0x67757300/uHTTP) +µHTTP 的出现源于对简单 Web 框架的需求。它非常适合微服务、单页应用程序以及单体(架构)这类庞然大物。 + +[PurpleLlama](https://github.com/facebookresearch/PurpleLlama) +用于评估和提高 LLM 安全性的工具集。 + +[Arrest](https://github.com/s-bose/arrest) +Arrest 是一个小型的实用程序,用以使用 pydantic 和 httpx 轻松构建和验证 REST API 调用。 + +[LLMCompiler](https://github.com/SqueezeAILab/LLMCompiler) +用于并行函数调用的 LLM 编译器。 + +[Pearl](https://github.com/facebookresearch/Pearl) +由 Meta 的应用强化学习团队带来的可投入生产的强化学习 AI 代理库。 + +[Mamba-Chat](https://github.com/havenhq/mamba-chat) +Mamba-Chat 是第一款基于状态空间模型架构而非转换器的聊天语言模型。 + +[Netchecks](https://github.com/hardbyte/netchecks) +Netchecks 是一组用于测试网络状况,并断言它们是否符合预期的工具。 + +[concordia](https://github.com/google-deepmind/concordia) +用于生成社会模拟的库。 + +[Cyclopts](https://github.com/BrianPugh/cyclopts) +基于 python 类型提示的直观、简单的 CLI。 + +[UniDep](https://github.com/basnijholt/unidep) +具有 pip 和 conda 要求的单一事实来源。 + + +# 最新发布 + +[Visual Studio Code 中的 Python - 2023 年 12 月版本](https://devblogs.microsoft.com/python/python-in-visual-studio-code-december-2023-release/) +此版本包括以下声明: +* 运行按钮菜单中添加了可配置的调试选项 +* 使用 Pylance 显示类型层次结构 +* 停用对终端中自动激活的虚拟环境的命令支持 +* 可设置打开/关闭 REPL 智能发送以及不支持时的消息 + + +[Python 3.12.1](https://www.python.org/downloads/release/python-3121/) \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_631.md b/Python Weekly/Python_Weekly_Issue_631.md new file mode 100644 index 0000000..7225630 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_631.md @@ -0,0 +1,110 @@ +原文:[Python Weekly - Issue 631](http://eepurl.com/iGGpqI) + +--- + +欢迎阅读《Python 周刊》第 631 期。这是2023年的最后一期。我们将在假期结束后回来。祝您及家人节日快乐!(译注:我也要去过节啦,大家节日快乐!!) + +# 新闻 + +[PyPI 的 2FA 要求,开始于 2024-01-01](https://blog.pypi.org/posts/2023-12-13-2fa-enforcement/) +从 2024 年 1 月 1 日开始,所有用户必须为其 PyPI 帐户启用双因素身份验证 (2FA) 才能执行任何管理操作或上传文件。此要求是 PyPI 为增强安全性所做的努力的一部分,仅需要浏览、下载和安装包的用户不会受到此更改的影响。 + + +# 文章,教程和讲座 + +[Requests vs Httpx vs Aiohttp | 选哪个?](https://www.youtube.com/watch?v=OPyoXx0yA0I) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频讨论了对应用程序中 API 通信的探索,比较了 requests、httpx 和 aiohttp 的使用。它展示了作者的首选项以及考虑该选择的理由。 + +[掌握使用 GitHub Copilot 进行 AI 配对编程的方法](https://github.com/microsoft/Mastering-GitHub-Copilot-for-Paired-Programming) +6 节课的课程,教授有关利用 GitHub Copilot 和 AI 配对编程资源所需了解的所有信息。 + +[Python 应用程序中的配置:没有魔法,只是必要的实践](https://robertrode.com/2023/10/02/configuration-in-python-applications-no-magic-just-necessary-practice.html) +本文探讨了 Python 应用程序中的配置实践,强调透明性的重要性并避免在此过程中使用魔法。它深入探讨了管理配置设置的实用方法,提倡 Python 应用程序开发中的清晰度和必要实践。 + +[GILad 中的 Balm:CPython 扩展的快速字符串构造](https://blog.vito.nyc/posts/gil-balm/) +一种优化在 Python 字符串上运行的 Python C 扩展的非正统方法。 + +[构建个人预测文本引擎](https://jamesg.blog/2023/12/15/auto-write/) +本文讨论了名为 AutoWrite 的个人预测文本引擎的开发过程,该引擎会考虑文档中已编写的单词,从而提供特定于上下文的自动完成功能。 + +[我是如何使用 Python 构建 Okta 文档聊天机器人的](https://developer.okta.com/blog/2023/12/20/okta-documentation-chatbot) +本文介绍了 Oktanaut 的开发过程,Oktanaut 是一个 Python 聊天机器人,可简化对 Okta 开发人员文档信息的访问。该聊天机器人是使用 OpenAI 和 Jupyter Notebook 创建的,并开发了两个版本来提供特定的方法和常识。第一个版本使用 LlamaIndex 并根据 Okta 的开发人员文档进行训练,基于其精度而生成准确的响应。 + +[安全哈希冲突](https://www.da.vidbuchanan.co.uk/blog/colliding-secure-hashes.html) +本文讨论了这么一个问题:作者使用 pyopencl 移植算法以在 GPU 上运行,导致安全哈希冲突。作者选择截断散列的中间部分而不是末尾部分,试图在视觉上欺骗某人比较全长散列的开头和结尾。 + +[可重用 Django 应用的设置模式](https://overtag.dk/v2/blog/a-settings-pattern-for-reusable-django-apps) +本文介绍了可重用 Django 应用程序的新设置模式,解决了使用项目设置覆盖应用程序默认设置的挑战。作者讨论了对清晰一致模式的需求,文章概述了建议的解决方案,其中涉及检查设置的前缀以避免返回 Django 设置的随机属性。 + +[DjangoCon US 2023 视频集](https://www.youtube.com/playlist?list=PL2NFhrDSOxgX41jqYSi0HmO9Wsf6WDSmf) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +DjangoCon US 2023 的 YouTube 视频集合,包含该活动的各种视频。它涵盖了与 Django 开发相关的一系列主题,包括在会议上展示的演讲、研讨会和讨论。 + +[异步任务取消的最佳实践](https://superfastpython.com/asyncio-task-cancellation-best-practices/) +在本教程中,您将发现在 Python 中取消异步任务的最佳实践。 + +[使用 Django 构建即时通讯工具(6 分钟内)](https://www.youtube.com/watch?v=-9h3Sjr2WKk) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频提供了有关使用 Django 创建即时通讯工具的快速教程。本教程旨在以简洁的方式演示该过程,使其成为那些对使用 Django 开发消息应用程序感兴趣的人来说有用的资源。 + +[理解 GPU 内存 1:可视化随时间变化的所有分配](https://pytorch.org/blog/understanding-gpu-memory-1/) +第一部分显示了使用内存快照工具的方法。 + + + * [第二部分](https://pytorch.org/blog/understanding-gpu-memory-2/) - 在这一部分中,我们将使用内存快照来可视化由循环引用引起的 GPU 内存泄漏,然后使用引用循环检测器在代码中定位并删除它们。 + + +[使用 APIFlask 来保持数据 DRY](https://buildwithlayer.github.io/buildwithlayer/blog/dry_with_apiflask/) +这篇文章讨论了如何使用 APIFlask(它的路由和模式符合 OpenAPI 规范)从而允许 API 文档的自动编写。它强调了保持数据 DRY(Don't Repeat Yourself,不要重复自己)的好处,以及在编写 API 时轻松记录 API 的好处。这篇文章深入介绍了 APIFlask 是如何帮助避免冗余代码,以及维护清晰简洁的代码库的。 + +[Python 陷阱:列表复制问题](https://andrewwegner.com/python-gotcha-list-copy.html) +复制 Python 列表(或任何可变对象)并不是将一个列表设置为另一个值那么简单。让我们讨论一个更好的方法来做到这一点。 + +[适用于 LLMs 的 Bash One-Liners](https://justine.lol/oneliners/) +六个可靠示例,说明 llamafile 是如何帮助您提高命令行使用效率的。 + +[实际上,你可以并行使用多少个 CPU 核心?](https://pythonspeed.com/articles/cpu-thread-pool-size/) +要弄清楚你的程序可以使用多少并行度是非常棘手的。 + +[Python 中 `key` 参数的关键之处](https://www.thepythoncodingstack.com/p/the-key-to-the-key-parameter-in-python) +名为 `key` 的参数存在于多个 Python 函数中,例如 `sorted()`。让我们探讨一下它是什么以及如何使用它。 + + +# 好玩的项目,工具和库 + +[OpenVoice](https://github.com/myshell-ai/OpenVoice) +一种多功能的即时语音克隆方法,只需要参考说话者的一个简短的音频剪辑即可复制他们的声音并生成多种语言的语音。 + +[PromptBench](https://github.com/microsoft/promptbench) +用于评估和理解大型语言模型的统一库。 + +[generative-ai-python](https://github.com/google/generative-ai-python) +Google AI Python SDK 使开发人员能够使用 Google 最先进的生成式 AI 模型(如 Gemini 和 PaLM)来构建 AI 驱动的功能和应用程序。 + +[TwitchDropsMiner](https://github.com/DevilXD/TwitchDropsMiner) +一款应用,允许您 AFK 挖掘定时 Twitch 掉落物,具有自动掉落物认领和频道切换功能。 + +[feud](https://github.com/eonu/feud/) +使用简单的惯用 Python 构建强大的 CLI,由类型提示驱动。 + +[microagents](https://github.com/aymenfurter/microagents) +能够自编辑提示/Python 代码的代理。 + +[django-ninja-crud](https://github.com/hbakri/django-ninja-crud) +声明式 CRUD 端点和测试,使用 Django Ninja。 + +[skytrack](https://github.com/ANG13T/skytrack) +使用 Python 制作的基于命令行的飞机定位和飞机 OSINT 侦察工具。 + +[resemble-enhance](https://github.com/resemble-ai/resemble-enhance) +AI 支持的语音去噪和增强。 + +[whisper-plus](https://github.com/kadirnar/whisper-plus) +高级语音到文本处理。 + +[mergekit](https://github.com/cg123/mergekit) +用于合并预训练大型语言模型的工具。 + +[llm-mistral](https://github.com/simonw/llm-mistral) +LLM 插件,提供对使用 Mistral API 的 Mistral 模型的访问。 + +[tinyzero](https://github.com/s-casci/tinyzero) +在您想的任何环境中轻松训练类似 AlphaZero 的智能体! diff --git a/Python Weekly/Python_Weekly_Issue_632.md b/Python Weekly/Python_Weekly_Issue_632.md new file mode 100644 index 0000000..ed23212 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_632.md @@ -0,0 +1,112 @@ +原文:[Python Weekly - Issue 632](http://eepurl.com/iHlBRk) + +--- + +欢迎阅读《Python 周刊》第 632 期。新年快乐!希望您度过了一个愉快的假期。 + + +# 新闻 + +[DjangoCon Europe 2024 CFP](https://pretalx.evolutio.pt/djangocon-europe-2024/cfp) + DjangoCon Europe 2024 参与呼吁,邀请提交演讲,其主题应涉及 Django 和 Python 开发。提案截止日期为 2024 年 3 月 1 日。 + + +# 文章,教程和讲座 + +[用 Python 读取 Excel 最快的方法](https://hakibenita.com/fast-excel-python) +用不到 4 秒读取 500K 行。 + +[面向 Python 爱好者的 Rust 编码简介 ](https://www.youtube.com/watch?v=MoqtsYLGCC4) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频首次探讨了使用 Rust 进行编码,深入探讨了它的炫酷功能,并与 Python 进行了比较。 + +[Microdot:另一个 Python Web 框架](https://blog.miguelgrinberg.com/post/microdot-yet-another-python-web-framework) +本文介绍了 Microdot,这是一个 Python Web 框架,具有类似 Flask 的语法、与 MicroPython 和 CPython 兼容、支持 asyncio 以及为 MicroPython 提供了一个最小的 Web 服务器,旨在满足 MicroPython 生态系统中对 Web 框架的需求。这篇文章还概述了 Microdot 的开发历史及其最近发布的完全异步的 2.0 版本。 + +[Fontimize:仅将字体精确地设置为您网站使用的字符](https://daveon.design/introducing-fontimize-subset-fonts-to-exactly-and-only-your-websites-used-characters.html) +Fontimize 是一个 Python 库,可以创建仅包含文本或 HTML 所需的特定字形的字体子集,从而减少网站的初始下载大小,进而优化带宽使用。 + +[如何让 LLM 更快](https://vgel.me/posts/faster-inference) +这篇文章是一篇长期而广泛的调查,探讨了一系列使 LLM 取得进展的不同方法(从更好的硬件利用率到巧妙的解码技巧)。 + +[Django:检测全局隐私控制信号](https://adamj.eu/tech/2023/12/27/django-global-privacy-control/) +在这篇文章中,我们将研究如何在 Django 项目中实现 GPC,并使用您可以进行调整的代码示例。由于 GPC 很简单,但需要非常依赖于具体情况的操作,因此很难为 Django 或第三方包构建任何特定的支持。 + +[不使用 git 进行提交](https://matheustavares.gitlab.io/posts/committing-without-git) +本文提供了一个实践教程,内容是使用 Python 创建具有两次提交的分支,旨在了解 Git 中的主要数据结构(称为“git 对象”)及其相互关系。这篇文章提供一些见解,涉及 Git 对象的不变性、使用 DEFLATE 算法进行压缩、以及通过其内容的 SHA-1 哈希进行引用,同时文中还警告不要在生产中使用该方法,因为由git 命令执行的安全检查和特别处理。 + +[针对 Flask、Django 和 FastAPI 微调 Python WSGI 和 ASGI 应用程序](https://tonybaloney.github.io/posts/fine-tuning-wsgi-and-asgi-applications.html) +在这篇文章中,重点是研究配置 Python Web 服务器(例如 Gunicorn、Uvicorn 和 Hypercorn)的最佳实践。它将总结Python代码和用户之间的组件架构,并讨论负载测试等验证方法,以确保配置能够承受用户流量。 + +[使用两塔方法(Two Tower Approach)和 Expedia Group 旅行者数据生成候选者](https://medium.com/expedia-group-tech/candidate-generation-using-a-two-tower-approach-with-expedia-group-traveler-data-ca6a0dcab83e) +建模环境和项目功能,以改进旅行者推荐。 + +[Python 陷阱:在迭代时修改列表](https://andrewwegner.com/python-gotcha-modify-list-while-iterating.html) +Python 可以让您在迭代列表元素时轻松修改列表。这种操作会反咬你一口。请继续阅读以了解它是如何阴你的,以及可以采取什么措施。 + +[AutoGluon-TimeSeries:创建强大的集合预测(Ensemble Forecast) - 完整教程](https://aihorizonforecast.substack.com/p/autogluon-timeseries-creating-powerful) +Amazon 的时间序列预测框架应有尽有。 + +[如何在 mac 上使用 cli 或免费使用 Python 进行 ocr ](https://blog.greg.technology/2024/01/02/how-do-you-ocr-on-a-mac.html) + +[一个实验性的pip子命令,用于Unix的Python启动器](https://snarky.ca/an-experimental-pip-subcommand-for-the-python-launcher-for-unix/) + +[在2024年的头几天学习 LLM 和编程](http://antirez.com/news/140) + + +# 好玩的项目,工具和库 + +[DocFlow](https://github.com/jiisanda/docflow) +DocFlow 是一个强大的文档管理 API,旨在简化文档处理,包括无缝上传、下载、组织、版本控制、共享等功能。 + +[Jake](https://github.com/thevahidal/jake) +在 GitHub 上轻松创建和部署您自己的单链接网站。 + +[Paracelsus](https://github.com/tedivm/paracelsus) +Paracelsus 通过读取 SQLAlchemy 模型来生成实体关系图。 + +[falco](https://github.com/tobi-de/falco) +增强您的 Django 开发体验:现代 Django 开发者的 CLI 和指南。 + +[AnyText](https://github.com/tyxsspa/AnyText) +多语言可视文本生成和编辑。 + +[mixtral-offloading](https://github.com/dvmazur/mixtral-offloading) +在 Colab 或者消费者桌面中运行 Mixtral-8x7B 模型。 + +[UForm](https://github.com/unum-cloud/uform) +袖珍多模态 AI,用于内容理解和生成,跨多语言文本、图像和视频,速度比 OpenAI CLIP 和 LLaVA 快了多至 5 倍。 + +[MotionCtrl](https://github.com/TencentARC/MotionCtrl) +用于视频生成的统一且灵活的运动控制器。 + +[semantic-router](https://github.com/aurelio-labs/semantic-router) +语义路由器是您的 LLM 和代理的超快速决策层。相比等待缓慢的 LLM 一代做出工具使用决策,我们利用语义向量空间的魔力来做出这些决策——使用语义来路由我们的请求。 + +[Autograd-from-scratch](https://github.com/eduardoleao052/Autograd-from-scratch) +从头开始​​记录并经过单元测试的教育性深度学习框架,仅使用 Numpy 构建。 + +[MobileVLM](https://github.com/Meituan-AutoML/MobileVLM) +适用于移动设备的快速、强大且开放的视觉语言助手。 + + +# 最新发布 + +[Django 错误修复版本已发布:4.2.9 和 5.0.1](https://www.djangoproject.com/weblog/2024/jan/02/bugfix-release/) + + +# 近期活动和网络研讨会 + +[Virtual: Cleveland Python 2024 年 1 月聚会](https://www.meetup.com/cleveland-area-python-interest-group/events/297549665/) +将会有一场演讲:使用开源包构建 LLM 支持的数据应用程序。 + +[Python Milano 2024 年 1 月聚会](https://www.meetup.com/python-milano/events/298086176/) +将有以下演讲: + * 少写,多测试 - 基于属性的测试简介 + * Dagster:现代数据编排器 + + +[PyData Toronto 2024 年 1 月聚会](https://www.meetup.com/pydatato/events/297368081/) +将有以下演讲: + * NumFOCUS - 那是什么? + * PyTorch 2.0 - 为什么你应该关心它? + diff --git a/Python Weekly/Python_Weekly_Issue_633.md b/Python Weekly/Python_Weekly_Issue_633.md new file mode 100644 index 0000000..42269c8 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_633.md @@ -0,0 +1,103 @@ +原文:[Python Weekly - Issue 633](http://eepurl.com/iHOxDc) + +--- + +欢迎来到《Python周刊》第 633 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[Python 3.13 有 JIT 啦](https://tonybaloney.github.io/posts/python-gets-a-jit.html) +2023 年 12 月下旬的时候,CPython 核心开发人员 Brandt Bucher 向 Python 3.13 分支提交了一个小的 Pull 请求,添加了 JIT 编译器。这一更改一旦被接受,就将是自 Python 3.11 中添加专用自适应解释器(pecializing Adaptive Interpreter)以来,CPython 解释器最大的更改之一。在这篇文章中,我们将了解这个 JIT,它是什么、它如何工作以及有什么好处。 + +[通过一个共享库集成 Rust 和 Python](https://www.youtube.com/watch?v=K9dUqGyQ9pw) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +了解如何在用 Rust 构建计算和内存密集型函数,并将它们无缝集成到 Python 脚本中。该视频内容涵盖了使用 pyo3 利用 Rust 创建共享 Python 模块、将 Rust 代码编译到共享对象文件中、在 Python 中导入该文件以及从 Python 调用高性能的 Rust 函数。 + +[保护你的 Flask 应用的最佳实践](https://escape.tech/blog/best-practices-protect-flask-applications/) +通过我们的专家实践教程,学习如何有效保护您的 Flask 应用程序。只需几个步骤即可增强项目的安全性! + +[Knuckledragger:实验 Python 证明助手](https://www.philipzucker.com/python-itp/) +我正在修改的东西是,用 python 制作一个证明助手。 + +[CI 上 Scrapy 链接验证的乐趣](https://www.mattlayman.com/blog/2024/fun-scrapy-validation-ci/) +如何自动确保站点内链接到其他内部页面的所有链接继续有效?在本文中,我们将了解如何使用 Scrapy(一种网页抓取工具)和 GitHub Actions(一种持续集成系统)来实现此目标。 + +[使用格式化程序和 linter 管理大型代码库](https://tech.octopus.energy/news/2024/01/05/linting-and-formatting.html) +在 Kraken Tech,我们拥有一支由 500 多名开发人员组成的大型全球开发团队,其中大多数人都在包含超过 400 万行 Python 代码的单体代码库上工作。我们每天发布新代码超过 100 次,在此过程中运行数十万次测试。那么,在变更如此频繁的情况下,要如何在分布式团队中确保高编码质量呢?此外,我们如何才能让新加入者更容易地加入并做出贡献? + +[深入探讨 Python 的 functools.wraps 装饰器](https://jacobpadilla.com/articles/Functools-Deep-Dive) +本文讨论了 Python 中 functools.wraps 装饰器的重要性。它解释了在将一个对象包装在另一个对象上时,特别是在开发 Python 装饰器时,装饰器是如何帮助保留元数据的。作者强调了这个装饰器的重要性,因为封装对象可能会丢失有价值的元数据。 + +[纯 Python 中的 SIMD](https://www.da.vidbuchanan.co.uk/blog/python-swar.html) +这篇文章探讨了 Python 环境下的 SWAR(寄存器中的 SIMD)及其变体 SWAB(Bigint 中的 SIMD)的概念。讨论了 SWAB(最大化每条 VM 指令完成的工作量)是如何在 Python 中发挥作用、减少解释器开销、并允许 CPU 将大部分时间花在实现整数运算的快速本机代码上。 + +[实验《纽约时报填字游戏》上的手写识别](https://open.nytimes.com/experimenting-with-handwriting-recognition-for-new-york-times-crossword-a78e08fec08f) +本文讨论了 MakerWeek 2023 黑客马拉松期间,针对《纽约时报填字游戏》应用程序中手写识别的探索。该项目涉及在 iOS 和 Android 平台上实现用于手写识别的设备端机器学习,它具有诸如“乱写乱画”检测和应用内自我训练机制​​等交互功能的潜力。 + +[Viberary 回顾](https://vickiboykis.com/2024/01/05/retro-on-viberary/) +本文反映了作者使用 Viberary 的经验,Viberary 是一个旨在根据特定氛围查找书籍的副项目。该项目的创建是为了探索机器学习副项目,以及搜索和推荐的交叉点,作为作者最近深入研究嵌入(embeddings)的生产级补充。 + +[将 AI 驱动的 Django 应用程序部署到 Modal.com](https://tolkunov.dev/posts/django-on-modal/) +Modal 是部署使用 AI 模型并需要 GPU 的 Python 应用程序的一个好地方。以下是如何将 Modal 与 Django 应用程序一起使用。 + +[NumPy 2 来啦:防止损坏,更新代码](https://pythonspeed.com/articles/numpy-2/) +NumPy 2 即将推出,并且向后不兼容。了解如何防止代码被破坏以及如何升级。 + +[Pandas 分析:详细说明](https://www.influxdata.com/blog/pandas-profiling-tutorial/) +Pandas 分析或现在所谓的 ydata-profiling,是通过 Python 提供的一个包,我们将在本文中介绍它并介绍如何使用它。 + +[数据分析师初学者训练营(SQL、Tableau、Power BI、Python、Excel、Pandas、项目等)](https://www.youtube.com/watch?v=PSNXoAs2FtQ) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +跟随这个大型课程成为一名数据分析师。您将学习数据分析师需要了解的核心主题。在此过程中,您会通过构建大量项目来获得实践经验。 + +# 好玩的项目,工具和库 + +[Open Interpreter](https://github.com/KillianLucas/open-interpreter) +计算机自然语言界面。 + +[Harlequin](https://github.com/tconbeer/harlequin) +适用于您的终端的 SQL IDE。 + +[crewAI](https://github.com/joaomdmoura/crewAI) +用于编排角色扮演、自主人工智能代理的尖端框架。通过促进协作智能,CrewAI 使代理能够无缝协作,以及处理复杂的任务。 + +[skfolio](https://github.com/skfolio/skfolio) +Python 库,用于构建基于 scikit-learn 的投资组合优化。 + +[aloha](https://github.com/tonyzhaozh/aloha) +用于双手远程操作的低成本开源硬件系统。 + +[selfextend](https://github.com/sdan/selfextend) +自扩展的实现,通过分组注意力扩展上下文窗口 + +[langgraph](https://github.com/langchain-ai/langgraph) +将语言代理构建为图表。 + +[psst](https://github.com/Sjlver/psst) +基于纸质的秘密共享技术。 + +[van-gonography](https://github.com/JoshuaKasa/van-gonography) +在您选择的图像中隐藏任何类型的文件。 + + +# 近期活动和网络研讨会 + +[DragonPy 2024 年 1 月聚会](https://www.meetup.com/ljubljana-python-group/events/298186535/) +将有以下演讲: +* 原谅我的 Python +* 从 P 到 P – 不同类型的 p2p +* Python 和能量学 + +[Bangalore 2024 年 1 月聚会](https://www.meetup.com/bangpypers/events/297639118/) +将有以下演讲: +* Micropython - 用于微控制器的 Python +* 是时候抛弃 requirements.txt 和 VENV 了,现在就开始使用Poetry +* 我是如何制作 dunderhell 的:最丑陋的 python 压缩器 + +[PyData Munich 2024 年 1 月聚会](https://www.meetup.com/pydata-munchen/events/298185256/) +将有以下演讲: +* 用于图像字幕的不同方法,为给定视觉输入预测字幕的任务 +* 从 LLM 到业务 - 在业务流程中扩展 LLM 应用程序。 + +[PyData Southampton 2024 年 1 月聚会](https://www.meetup.com/pydata-southampton/events/298281776/) +将有以下演讲: +* OpenAI 的函数调用:它是什么以及我们要如何利用它? +* 为非政府组织构建数据科学解决方案,即使你不知道它会在什么样的基础设施上运行:预测导师供需不匹配的案例研究 \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_634.md b/Python Weekly/Python_Weekly_Issue_634.md new file mode 100644 index 0000000..027cbb2 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_634.md @@ -0,0 +1,131 @@ +原文:[Python Weekly - Issue 634](http://eepurl.com/iIfkrc) + +--- + +欢迎来到《Python周刊》第 634 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[构建可用于生产的 FastAPI 后端的 4 个技巧](https://www.youtube.com/watch?v=XlnmN4BfCxw) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频讨论了您在大多数 FastAPI 在线教程中通常找不到的 4 件事。这些技巧非常有用,特别是如果您想创建可以在生产环境中使用的后端。 + +[Python 打包,一年后:Python 打包 2023 年回顾](https://chriswarrick.com/blog/2024/01/15/python-packaging-one-year-later/) +一年前,我写了一篇关于 Python 打包的悲催状态的文章。这个领域有大量的工具,强调编写模糊的标准而不是围绕一个真正的工具展开,还关注复杂的基于 venv 的生态系统而不是类似于 node_modules 的解决方案。那么,过去一年发生了什么变化呢?有什么改善吗?一切都还维持原样吗?或者情况比以前更糟了吗? + +[用于更快的 Python C 扩展的类型信息](https://bernsteinbear.com/blog/typed-c-extensions/) +PyPy 是 Python 语言的替代实现。PyPy 的 C API 兼容性层存在着一些性能问题。Carl Friedrich Bolz-Tereick 和我正在研究一种使 PyPy 的 C API 交互速度更快的方法。它看起来非常有前途。这里是其工作原理的草图。 + +[AlphaGeometry:奥林匹克级别的几何 AI 系统](https://deepmind.google/discover/blog/alphageometry-an-olympiad-level-ai-system-for-geometry/) +这篇文章介绍了 AlphaGeometry,这是一个人工智能系统,可以解决复杂的几何问题,其水平接近人类奥林匹克金牌得主。本文重点介绍了该系统在标准时限内解决了 30 道奥林匹克几何问题中的 25 道的表现,反映了其在数学人工智能推理方面的重大进步。它提供了对 AlphaGeometry 的发展和功能的见解,将其定位为人工智能用于解决几何问题领域的突破性成就。 + +[用一行代码即可节省 1 TB RAM](https://www.youtube.com/watch?v=Hgw_RlCaIds) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +Anthony Sottile 展示了他在工作中所做的一个产生巨大影响的小改变,并解释了它是如何工作的! + +[我们是如何对 PyTorch 执行关键的供应链攻击的](https://johnstawinski.com/2024/01/11/playing-with-fire-how-we-executed-a-critical-supply-chain-attack-on-pytorch/) +这篇文章讨论了对 PyTorch 的供应链攻击的执行,强调了潜在影响以及破解 PyTorch 供应链的途径。它深入研究了漏洞识别、攻击执行以及此类攻击在网络安全和供应链完整性背景下的重要性。 + +[潜伏者代理(Sleeper Agents):训练持续通过安全性训练的欺骗性 LLM](https://arxiv.org/pdf/2401.05566.pdf) +该研究探讨了大型语言模型 (LLM) 如何能够表现出持久性欺骗行为,例如根据指定的年份编写安全代码,但在年份发生变化时引入可利用的代码。当前的安全训练技术,包括监督微调和对抗性训练,很难检测和消除这些欺骗性策略,引发了人们对确保人工智能安全的标准方法有效性的担忧。 + +[数据代码的结构应该有多好?](https://blog.dagworks.io/p/how-well-structured-should-your-data) +这篇文章探讨了性能和系统可靠性之间的权衡,特别是在数据科学的背景下。它深入探讨了 ML 模型原型设计者所面临的挑战,讨论了快速行动的压力,以及放弃工作还是担任生产中机器学习工程师角色的决策过程。 + +[GPT 中自注意力的直观指南:威尼斯假面舞会](https://twiecki.io/blog/2024/01/04) +这篇文章讨论了 Transformer 架构中的自注意力机制(self-attention mechanism),使用威尼斯假面舞会的隐喻来解释现代人工智能中的这一概念。它的目的是通过提供直观且相关的解释,远离压倒性的数学细节和技术术语,使复杂的自注意力概念更容易理解。 + +[Flask 中的另一个密码重置教程](https://freelancefootprints.substack.com/p/yet-another-password-reset-tutorial) +密码重置流程的实现,有一些变化。 + +[使用 Python 创建 UI - 使用 PyQt5 创建音乐播放器](https://www.youtube.com/watch?v=DjutoyfCl2c) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +通过使用 PyQt5 框架创建现代音乐播放器来了解如何使用 Python 创建 UI。该应用程序的一些功能包括:美丽而现代的用户界面、播放列表和最喜爱的歌曲功能、不同页面的自定义上下文菜单以及每首歌曲的背景幻灯片。 + + +[Polars 简介](https://pbpython.com/polars-intro.html) +本文概述了 Polars DataFrame 库,强调其目标是提供快如闪电的 DataFrame 库,以优化查询、处理大型数据集并维护一致且可预测的 API。它将 Polars 与其他解决方案进行了比较,并介绍了那些使其成为 Python 中高性能数据操作和分析的引人注目的选项的设计决策。 + +[在空气隔离系统上运行 Python](https://iahmed.me/post/python-air-gapped/) +如何在无法访问 Internet 的系统上可重复地运行 Python 代码。 +> 译注:空气隔离指计算机或计算机网络与其他设备或网络之间没有物理连接,以防止数据泄露或恶意攻击。 + +[Python 中的同步](https://thiagowfx.github.io/2024/01/synchronized-in-python/) +在Java中,只需添加 synchronized 关键字就可以使变量线程安全。在Python中可以通过什么东西来达到相同的结果吗? + +[避免黑盒 API 调用](https://rednafi.com/misc/eschewing_black_box_api_calls/) + +[htmx 是可组合的??](https://timkellogg.me/blog/2024/01/17/htmx) + +[The curious case of Pydantic 的奇怪案例,以及 1970 年代的时间戳](https://dev.arie.bovenberg.net/blog/pydantic-timestamps/) + + + # 好玩的项目,工具和库 + +[marimo](https://github.com/marimo-team/marimo) +一个反应式 Python notebook,可复制、git 友好且可作为脚本或应用程序部署。 + +[surya](https://github.com/VikParuchuri/surya) +适用于任何语言的精确行级文本检测和识别 (OCR)。 + +[pathway](https://github.com/pathwaycom/pathway) +Pathway 是一个高吞吐量、低延迟的数据处理框架,可以为您处理实时数据和流。 + +[DataMapPlot](https://github.com/TutteInstitute/datamapplot) +创建漂亮的数据地图。 + +[Python-Redlines](https://github.com/JSv4/Python-Redlines) +Docx 跟踪了 Python 生态系统的变更红线。 + +[phidata](https://github.com/phidatahq/phidata) +使用 LLM 函数调用构建自主助手。 + + + # 近期活动和网络研讨会 + +[IndyPy 2024 年 1 月聚会](https://www.meetup.com/indypy/events/297838473/) + +将会有一场演讲,高级模块和AI,针对小白。 + +[ThaiPy - Bangkok Python 2024 年 1 月聚会](https://www.meetup.com/thaipy-bangkok-python-meetup/events/297400014/) +将有以下演讲: + * 使用 Python 和 Apache Kafka 进行流处理 + * 为什么大型语言模型需要稀疏向量? + + +[Python Barcelona 2024 年 1 月聚会](https://www.meetup.com/python-barcelona/events/298506663/) +将有以下演讲: + * 在公司内启动自己的Python库 + * 使用 PyPDF 掌握 PDF 表单填写 + + +[PyLadies Paris 2024 年 1 月聚会](https://www.meetup.com/pyladiesparis/events/298401634/) +将有以下演讲: + * 利用机器学习进行慢性肾脏病的早期检测 + * 了解 SEO 对比测试:针对搜索引擎进行优化 + + +[Virtual: PyData Chicago 2024 年 1 月聚会](https://www.meetup.com/pydatachi/events/298499243/) +将会有一场演讲,Securday:自然语言网络扫描仪。 + +[PyData Zurich 2024 年 1 月聚会](https://www.meetup.com/pydata-zurich/events/298392043/) +将有以下演讲: + * Vega-Altair:一个简单、友好且功能强大的数据可视化库 + * 关于数据科学软技能的故事 + + +[PyData Milano 2024 年 1 月聚会](https://www.meetup.com/pydata-milano/events/298391373/) +将有以下演讲: + + * 谁需要 ChatGPT?使用 Hugging Face 和 Kedro 打造坚如磐石的 AI 管道 + * 在 Vertex AI 上使用 Ray 解锁可扩展的机器学习 + + +[PyData Sudwest 2024 年 1 月聚会](https://www.meetup.com/pydata-suedwest/events/296355526/) +将有以下演讲: + * 转变您的业务:通过数据运营实现数据驱动的路线图 + * 使用 LakeFS 和 LakeFS-Spec 进行数据版本控制 + * 把我的数据留在这里!以节省数据的方式实现人工智能助手 + + +[PyData Prague 2024 年 1 月聚会](https://www.meetup.com/pydata-prague/events/298421104/) +将有以下演讲: + * 使用 BirdNET 进行人工智能驱动的生物声学监测 + * (不仅仅是)大型语言模型成功背后的数据 \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_635.md b/Python Weekly/Python_Weekly_Issue_635.md new file mode 100644 index 0000000..1a26e04 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_635.md @@ -0,0 +1,122 @@ +原文:[Python Weekly - Issue 635](http://eepurl.com/iIKcaE) + +--- + +欢迎来到《Python周刊》第 635 期。让我们直奔主题。 + + +# 文章,教程和讲座 + +[andas 中的方法链](https://www.youtube.com/watch?v=39MEeDLxGGg) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +什么是 Pandas 中的方法链?它是如何工作的以及如何使用它? + +[在 Python 中,构建优先级-到期时间(priority-expiry) LRU 缓存,无需使用堆或者树](https://death.andgravity.com/lru-cache) +了解如何仅使用 Python 标准库,实现具有优先级和到期时间的最近最少使用缓存。 + +[scrapscript.py](https://bernsteinbear.com/blog/scrapscript/) +文章介绍了一种小型、纯粹、函数式、内容可寻址、网络优先的编程语言,旨在创建小型、可共享的程序。它讨论了该语言的功能及其实现,强调了其目的及其开发背后的协作努力。本文深入探讨了 Scrapscript 的动机和设计原则,以及其创建和实施过程中涉及的协作过程。 + +[矢量数据库的性能](https://www.youtube.com/watch?v=-MYYB0QjV6I) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +本次演讲探讨了矢量数据库在增强检索增强生成(Retrieval-Augmented Generation,RAG)等人工智能应用中的作用,重点关注对机器学习至关重要的高维嵌入。Egor Romanov 深入研究创建一个与 pgvector 集成的 Postgres 提供程序,利用 Python 性能评估框架来模拟相似性搜索测试并揭示潜在的性能潜力。 + +[Python 的 dict() 和 {} 的性能分析](https://madebyme.today/blog/python-dict-vs-curly-brackets/) +这篇文章探讨了在 Python 中使用 dict() 和 {} 创建字典的差异。它深入研究了它们的功能、性能和最佳实践,提供了有关在 Python 编码中使用每种方法的场景的见解。 + +[自动化部署的可怕之处](https://slack.engineering/the-scary-thing-about-automating-deploys/) +Slack Engineering 的文章讨论了对破坏生产的恐惧,这种恐惧阻碍了许多团队实现部署自动化。它强调了了解部署监控与正常监控有何不同的重要性,以及为缓解这些担忧而采取的迭代方法,从而最终实现成功的自动化部署。本文深入探讨了自动化部署流程的挑战和好处,解决了与网络安全和应用程序部署等各个领域的自动化系统相关的恐惧和担忧。 + +[Python 打包一定会变得更好 —— 一个数据点](https://lukeplant.me.uk/blog/posts/python-packaging-must-be-getting-better-a-datapoint/) +我在 Windows 上 “pip install”了我的应用,一切都正常了。事情进展顺利。 + +[增强 Markdown 语言以实现出色的 Python 图形界面](https://www.taipy.io/posts/augmenting-the-markdown-language-for-great-python-graphical-interfaces) +本文探讨了 Taipy 研发团队开发的增强 Markdown API,该 API 通过添加标签以直接在内容中生成图形界面元素,从而扩展了 Markdown 的简单性。这项创新旨在增强 Python 开发人员创建基于 Web 的界面的能力,提供一种在 Markdown 文档中集成图形元素的独特方法。 + +[使用语义图和 RAG,生成知识](https://neuml.hashnode.dev/generate-knowledge-with-semantic-graphs-and-rag) +使用语义图和 RAG 进行知识探索和发现。 + +[Python 数据分析和可视化课程 —— 天文数据](https://www.youtube.com/watch?v=H9KefzbryEw) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +使用真实世界的天文数据学习数据分析、数据可视化和图像处理技术。该课程提供了一种实用的实践方法来简化数据分析中的复杂概念,非常适合初学者。 + +[Django 中简单的 Google 登录](https://www.youtube.com/watch?v=NM9BE0iUB5Q) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +我们将以最简单的方式将 Google 登录添加到 Django 中(不使用 Django-all-auth 或 Django-social-auth 或任何其他大的包)。 + + + # 书籍 + +[ml-engineering](https://github.com/stas00/ml-engineering) +机器学习工程开放书籍。 + + + # 好玩的项目,工具和库 + +[DataTrove](https://github.com/huggingface/datatrove) +通过提供一组与平台无关的可定制管道处理块,将数据处理从疯狂的脚本中解放出来。 + +[Granian](https://github.com/emmett-framework/granian) +用于 Python 应用程序的 Rust HTTP 服务器。 + +[InstantID](https://github.com/InstantID/InstantID) +在几秒钟内 Zero-shot 生成身份保留。 + +[finagg](https://github.com/theOGognf/finagg) +一个 Python 包,用于聚合来自流行且免费的金融 API 的历史数据,并将该数据转换为适用于 AI/ML 的特征。 + +[Python-Type-Challenges](https://github.com/laike9m/Python-Type-Challenges) +通过交互式在线练习,掌握 Python 类型(类型提示)! + +[django-webhook](https://github.com/danihodovic/django-webhook) +传出 Django webhook,由模型更改触发。 + +[ULWGL-launcher](https://github.com/Open-Wine-Components/ULWGL-launcher) +统一 Linux Wine 游戏启动器。 + +[RAGxplorer](https://github.com/gabrielchua/RAGxplorer) +可视化并探索您的 RAG 文档。 + +[FastHX](https://github.com/volfpeter/fasthx) +FastAPI 和 HTMX,正确之道。 + +[TaskingAI](https://github.com/TaskingAI/TaskingAI) +为 AI 原生应用程序开发的开源平台。 + +[Applio](https://github.com/IAHispano/Applio) +Ultimate 语音克隆工具,经过精心优化,具有无与伦比的功能、模块化和用户友好的体验。 + +[wafer](https://github.com/sysdig/wafer) +Wafer 是一个简单但有效的 Web 应用程序防火墙 (web application firewall,WAF) 模糊测试工具。 + +> 译注:模糊测试(fuzz testing, fuzzing)是一种软件测试技术。 其核心思想是将**自动或半自动生成的随机数据**输入到一个程序中,并监视程序异常,如崩溃,断言(assertion)失败,以发现可能的程序错误,比如内存泄漏。 模糊测试常常用于检测软件或计算机系统的安全漏洞。 —— 来自维基百科 + +[SGLang](https://github.com/sgl-project/sglang) +SGLang 是一种专为大型语言模型 (LLM) 设计的结构化生成语言。它使您与 LLM 的互动更快、更可控。 + + + # 近期活动和网络研讨会 + +[PyBerlin 43](https://www.meetup.com/pyberlin/events/297958692/) +将有以下演讲: + * 生成结果的会议 + * f-strings:它们还能变得更好吗? + * 在 doctari 衡量软件交付性能 + + +[PyData Lancaster 2024 年 1 月聚会](https://www.meetup.com/pydata-lancaster/events/298462888/) +将有以下演讲: + * Earth My Friend:使用开源工具绘制 20 世纪 50 年代的环球航行图 + * 从代码库到软件 + +[PyData Copenhagen 2024 年 2 月聚会](https://www.meetup.com/pydata-copenhagen/events/298422850/) +将有一场演讲,即技术领域的增强检索:LLM 在实践中的挑战和机遇。 + +[PyData Lausanne 2024 年 2 月聚会](https://www.meetup.com/pydata-lausanne/events/298636167/) +将有以下演讲: + * 使用 DVC 和 CML 的 MLOps + * 抑制测试噩梦:使用 pytest 进行简单可靠的测试 + * 忘记打印语句:如何使用 VSCode 的调试器来简化你的生活 + + +[PyData Montreal 2024 年 2 月聚会](https://www.meetup.com/pydata-mtl/events/298407655/) +将有以下演讲: + * 理解语义搜索 + * 加拿大贝尔 NLP 语音团队对提取式问答变压器的探索 + * LLM 微调和部署简介 diff --git a/Python Weekly/Python_Weekly_Issue_636.md b/Python Weekly/Python_Weekly_Issue_636.md new file mode 100644 index 0000000..02d7bfd --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_636.md @@ -0,0 +1,103 @@ +原文:[Python Weekly - Issue 636](http://eepurl.com/iJcDOI) + +--- + +欢迎来到《Python周刊》第 636 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[面向 Python 程序员的 CUDA 入门](https://www.youtube.com/watch?v=nOxKexn3iBo) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在本教程中,Jeremy Howard 揭开了 NVIDIA GPU 的 CUDA 编程的神秘面纱,特别关注其与 PyTorch 结合使用时的可访问性。该实践教程在 Colab 笔记本中进行,引导观看者完成实际示例,从简单的任务(例如将 RGB 图像转换为灰度)开始,然后进展到更高级的主题(例如矩阵乘法)。重点是简化 Python 程序员的 CUDA 编程过程,提高调试难度和开发效率。 + +[深入研究 Python 中的存储库设计模式](https://www.youtube.com/watch?v=9ymRLDfnDKg) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +仔细研究 Python 中的存储库设计模式(repository design pattern)。这是一个非常有用的模式,允许您将数据存储与数据操作分开。 + +[鸟瞰 Polars](https://pola.rs/posts/polars_birds_eye_view) +了解 Polars 是如何执行您的查询(从规划、优化到执行)的。 + +[分析您的 Numba 代码](https://pythonspeed.com/articles/numba-profiling/) +了解如何使用 Profila 分析器来查找 Numba 代码中的性能瓶颈。 + +[十个 Python datetime 陷阱,以及库正在(未)采取哪些措施](https://dev.arie.bovenberg.net/blog/python-datetime-pitfalls/) +本文探讨了 Python 的 datetime 库中的各种挑战和不一致之处,以及不同的第三方库是如何解决这些问题的。 + +[使用图像和视频,利用 Vision API 探索 GPT-4](https://jstoppa.com/posts/exploring_the_gpt_with_vision_api_image_and_video/post/) +要理解如何利用 Vision API 使用 GPT-4,您所需要了解的一切,以及图像和视频的处理示例。 + +[将 Python 和 Rust 混合用于生产 CLI ](https://www.youtube.com/watch?v=GBZoWervz3s) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频概述了组合 Python 和 Rust 的有效工作流程 - 使用 PyO3 从 Rust CLI 调用 Python、利用 Rust 的安全性和 Python 的库、添加测试来验证逻辑、自动化流程并向用户提供二进制文件。 + +[使用 Python 运行开源 LLM —— 实践指南](https://christophergs.com/blog/running-open-source-llms-in-python) +在你的笔记本电脑上释放 AI 的力量。 + +[使用 Pylasu 实现解析器](https://tomassetti.me/implement-parsers-with-pylasu/) +在这篇文章中,我们将学习如何使用 Pylasu 和 ANTLR,用 Python 实现解析器。 + +[构建一个 Django AI 着色应用](https://www.youtube.com/watch?v=-04pgby8tVE) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +我们将构建一个简单的 Django 应用程序,它使用 AI 为黑白照片着色。我还将指导您完成在 Django 中使用 webhook 的最简单方法。 Webhook 是外部函数(例如 AI 函数)向服务器发送数据的一种巧妙方式。 + +[在 pytest 中修补 pydantic 设置](https://rednafi.com/python/patch_pydantic_settings_in_pytest/) +这篇文章讨论了有关在 Pytest 中修补 Pydantic 设置的 Python 教程。它涵盖了在 Pytest 环境中,测试期间修改 Pydantic 设置的技术,为有效的测试和开发工作流程提供了实用的见解。 + + +# 好玩的项目,工具和库 + +[gpt-newspaper](https://github.com/assafelovic/gpt-newspaper) +一个创新的自主代理,旨在根据用户偏好创建个性化报纸。 GPT Newspaper 利用人工智能的力量,根据个人品味和兴趣策划、撰写、设计和编辑内容,彻底改变了我们消费新闻的方式。 + +[excelCPU](https://github.com/InkboxSoftware/excelCPU) +用于 Excel 的 16 位 CPU,以及相关文件。 + +[FastCRUD](https://github.com/igorbenav/fastcrud) +FastCRUD 是 FastAPI 的 Python 包,提供强大的异步 CRUD 操作和灵活的端点创建能力。 + +[EasyGmail](https://github.com/ayushgun/easygmail) +一个轻量级、极简且同步的 Python 包,用于通过 Gmail 快速发送电子邮件。 + +[StreamRAG](https://github.com/video-db/StreamRAG) +视频搜索和流媒体代理。 + +[fabric](https://github.com/danielmiessler/fabric) +Fabric 是一个开源框架,用于使用人工智能增强人类能力。 + +[llm-app-stack](https://github.com/a16z-infra/llm-app-stack) +LLM 应用程序的新兴架构。 + + +# 近期活动和网络研讨会 + +[Django London 2024 年 2 月聚会](https://www.meetup.com/djangolondon/events/298796486/) +将会有一场演讲,即经过实战考验的技巧,以最大限度地从技术事件中学习。 + +[Python Milano 2024 年 2 月聚会](https://www.meetup.com/python-milano/events/298739054/) +将有以下演讲: + * 使用 Hamilton 构建特征存储 + * 扩展机器学习训练和推理 @Vedrai + + +[PyData Sudwest 2024 年 2 月聚会](https://www.meetup.com/pydata-suedwest/events/296355526/) +将有以下演讲: + * 转变您的业务:通过数据运营(Data Ops)实现数据驱动的路线图 + * 使用 LakeFS 和 LakeFS-Spec 进行数据版本控制 + * 我的数据留在这里!以节省数据的方式实现人工智能助手 + + +[PyData London 2024 年 2 月聚会](https://www.meetup.com/pydata-london-meetup/events/298028513/) +将有以下演讲: + * 不那么数据科学家的工具箱 + * 通过实时流处理促进相似性搜索 + * 开源科学 (Open-Source Science,OSSci) + * 在 GPU 上使用 CuDF (也许)更快的 Pandas(也许) + + +[PyData Tel Aviv 2024 年 2 月聚会](https://www.meetup.com/pydata-tel-aviv/events/298392671/) +将有以下演讲: + * 使用 DS 优化广告转化 + * 通过颜色矢量选择(color vector selection)使 Feed 多样化 + * 使用 LLM 将自由文本转换为结构 + + +[PyData Amsterdam 2024 年 2 月聚会](https://www.meetup.com/pydata-nl/events/298750712/) +将有以下演讲: + * 晚餐吃什么?构建 ML 平台以增强 Picnic 的在线杂货购物体验 + * 使用 Cleanlab 实现大规模自动化数据质量 diff --git a/Python Weekly/Python_Weekly_Issue_637.md b/Python Weekly/Python_Weekly_Issue_637.md new file mode 100644 index 0000000..328d99b --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_637.md @@ -0,0 +1,94 @@ +原文:[Python Weekly - Issue 637](http://eepurl.com/iJGNIs) + +--- + +欢迎来到《Python周刊》第 637 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[Rye:轻松的 Python 体验](https://www.youtube.com/watch?v=q99TYA7LnuA) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +演示了当时最新版本的 Rye (0.21),而现在它可用于管理 Python 项目和解释器。 + +[用 80 行代码实现的搜索引擎](https://www.alexmolas.com/2024/02/05/a-search-engine-in-80-lines.html) +这篇文章详细介绍了如何仅用 80 行代码创建搜索引擎的过程,提供了关于如何有效实现虽然基本但实用的搜索算法的见解。 + +[超越自注意力:小型语言模型是如何预测下一个 Token 的](https://shyam.blog/posts/beyond-self-attention) +深入研究小型变压器模型的内部结构,了解它如何将自注意力计算转化为下一个令牌的准确预测。 + +[Python 版本间的主要变动的总结](https://www.nicholashairs.com/posts/major-changes-between-python-versions/) +这篇文章旨在作为有关每个新版本 Python 引入的主要更改的快速参考。这可以帮助您在升级代码库时利用新功能,或者确保您拥有与旧版本兼容的正确的保护措施。 + +[专业提示 —— “丰富(rich)”你的 Python 测试](https://www.revsys.com/tidbits/en-rich-your-python-testing/) +本文提供了有关使用“rich”库来增强 Python 测试的专业提示。它演示了如何通过使用“rich”来更好地可视化测试结果,从而改进测试(特别是在 pytest 测试中)输出。本文提供了丰富 Python 测试体验的实用建议和代码示例。 + +[如何使用 GDB 的 Python API 缓存数据](https://developers.redhat.com/articles/2024/02/05/how-cache-data-using-gdbs-python-api#caching_for_object_files_and_program_spaces) +本文介绍如何在 GDB 的 Python API 中缓存不同对象类型的信息;它为缓存某些对象类型提供了特殊支持,而对于其他对象类型,您需要执行额外的工作来管理缓存的数据。 + +[使用 Django、Kubernetes、TailwindCSS、Twingate、AWS S3 和 HTMX 构建内容引擎](https://www.youtube.com/watch?v=2TX7Pal5NMc) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) + +[一万亿行挑战](https://blog.coiled.io/blog/1trc.html) + +[使用种子数据库改进 Django 测试](https://tla.wtf/posts/django-seed-db/) + +[TensorFlow 中的图形神经网络](https://blog.research.google/2024/02/graph-neural-networks-in-tensorflow.html) + + + # 好玩的项目,工具和库 + +[OLMo](https://allenai.org/olmo) +真正开放的最先进的 LLM和框架。 + +[Lockbox](https://github.com/mkjt2/lockbox) +Lockbox 是用于进行第三方 API 调用的转发代理。 + +[skorche](https://github.com/AnsBalin/skorche) +Python 的任务编排。 + +[PyPDFForm](https://github.com/chinapandaman/PyPDFForm) +处理 PDF 表单的 Python 库。 + +[rexi](https://github.com/royreznik/rexi) +用于正则表达式测试(Regex Testing)的终端UI。 + +[GPTAuthor](https://github.com/dylanhogg/gptauthor) +GPTAuthor 是一款 AI 工具,用于根据故事提示编写长篇、多章节的故事。 + +[django-htmx-components](https://github.com/iwanalabs/django-htmx-components) +这是 Django 和 htmx 的组件集合。它们旨在复制粘贴到您的项目中即可使用,还支持根据您的需求进行定制。 + +[contrastors](https://github.com/nomic-ai/contrastors) +contrastors 是对比学习工具包,使研究人员和工程师能够有效地训练和评估对比模型。 + +[Rawdog](https://github.com/AbanteAI/rawdog) +通过生成并自动执行 Python 脚本进行响应的 CLI 助手。 + +[IOPaint](https://github.com/Sanster/IOPaint) +一款由 SOTA AI 模型提供支持的免费开源图像修复工具。 + +[NaturalSQL](https://github.com/cfahlgren1/natural-sql) +一系列性能最佳的文本到 SQL LLM。 + +[ml-mgie](https://github.com/apple/ml-mgie) +Apple 全新开源 AI 模型,可以根据自然语言指令编辑图像。 + +[atopile](https://github.com/atopile/atopile) +一种用代码创建电子电路板的工具。 + +[web2pdf](https://github.com/dvcoolarun/web2pdf) +将网页转换为 PDF 对 CLI。 + + + # 最新发布 + +[Python 3.12.2 和 3.11.8 现已发布。](https://pythoninsider.blogspot.com/2024/02/python-3122-and-3118-are-now-available.html) + +[Django 安全版本现已发布:5.0.2、4.2.10 和 3.2.24](https://www.djangoproject.com/weblog/2024/feb/06/security-releases/) + + + # 近期活动和网络研讨会 + +[Python Frederick 2024 年 2 月聚会](https://www.meetup.com/python-frederick/events/298531232/) +将会有一场演讲:使用 Python 对算法艺术。 + +[PyData Johannesburg 2024 年 2 月聚会](https://www.meetup.com/pydata-johannesburg/events/298808404/) +将会有一场演讲:生产化机器学习模型。 diff --git a/Python Weekly/Python_Weekly_Issue_638.md b/Python Weekly/Python_Weekly_Issue_638.md new file mode 100644 index 0000000..185ed38 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_638.md @@ -0,0 +1,108 @@ +原文:[Python Weekly - Issue 638](http://eepurl.com/iJ9pdc) + +--- + +欢迎来到《Python周刊》第 638 期。让我们直奔主题。 + + +# 文章,教程和讲座 + +[为什么 AI 会遇到 Python 问题](https://www.youtube.com/watch?v=cGgTvMmtzNU) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +人工智能 (AI) 已将 Python 变得前所未有的流行,使其成为全球开发人员和研究人员的首选语言。然而,繁荣背后,一个巨大的挑战隐而未现。让我们通过现实世界的示例和技术见解来了解 Python 给人工智能发展带来的具体困难。 + +[Meta 超爱 Python 的](https://engineering.fb.com/2024/02/12/developer-tools/meta-loves-python/) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/9a9a57d0-eb4b-47f8-8af4-55ba50e8c350.png) +Meta 工程师讨论了他们对 Python 3.12 的贡献,包括自定义 JIT hook、永久对象、类型系统改进和更快的理解等新功能,强调了他们与 Python 社区的合作以及公司对开源计算的支持 + +[计算 Python 中使用的 CPU 指令](https://blog.mattstuchlik.com/2024/02/08/counting-cpu-instructions-in-python.html) +您知道用 Python 打印(“Hello”)需要大约 17,000 个 CPU 指令吗?而导入 Seaborn 则需要大约 20 亿个? + +[不仅仅是 NVIDIA:可以在任何地方运行的 GPU 编程](https://pythonspeed.com/articles/gpu-without-cuda/) +如果您想在 CI、Mac 等设备上运行 GPU 程序,wgu-py 是一个不错的选择。 + +[部署模型的多种方法](https://outerbounds.com/blog/the-many-ways-to-deploy-a-model) +部署模型和执行推理的方法有很多种。在这里,我们以 LLM 推理为例分享模型部署的决策准则。 + +[Adam 优化器背后的数学](https://towardsdatascience.com/the-math-behind-adam-optimizer-c41407efe59b) +为什么 Adam 是深度学习中最受欢迎的优化器?让我们通过深入研究其数学并重新创建算法来理解它。 + +[可视化神经网络内部结构](https://www.youtube.com/watch?v=ChfEO8l-fas) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +可视化神经网络在训练和推理过程中的一些内部结构。 + +[LLM 应用开发的工程实践](https://martinfowler.com/articles/engineering-practices-llm.html) +LLM 工程涉及的不仅仅是 prompt 设计或 prompt 工程。在本文中,我们分享了一组工程实践,帮助我们在最近的项目中快速可靠地交付原型 LLM 应用程序。我们将分享 LLM 应用程序的自动化测试和对抗性测试、重构技术,以及构建 LLM 应用程序和负责任的 AI 所需要注意的事项。 + +[Python 的 textwrap 模块可以做到的一切](https://martinheinz.dev/blog/108) + +Python 有许多用于格式化字符串和文本的选项,包括 f 字符串、format() 函数、模板等。然而,有一个模块很少有人知道,它叫做 textwrap。该模块是专门为帮助您进行换行、缩进、修剪等操作而构建的,在本文中我们将向您介绍您可以使用它来完成的所有操作。 + +[如果可以的话,如何避免在 Django 中进行计数查询](https://www.peterbe.com/plog/how-to-avoid-a-count-query-in-django-if-you-can) + +[像专家一样处理 Asyncio 中的任务](https://jacobpadilla.com/articles/handling-asyncio-tasks) + + +# 好玩的项目,工具和库 + +[modguard](https://github.com/Never-Over/modguard) +一个用于强制执行模块化、解耦包架构的 Python 工具。 + +[metavoice-src](https://github.com/metavoiceio/metavoice-src) +像人一样的富有表现力的 TTS 的基础模型。 + +[logot](https://github.com/etianen/logot) +测试您的代码是否正确进行了日志记录。 + +[TriOTP](https://github.com/linkdd/triotp) +Python Trio 的 OTP 框架。 + +[Toolong](https://github.com/textualize/toolong) +用于查看、追踪、合并和搜索日志文件(以及 JSONL)的终端应用程序。 + +[django-queryhunter](https://github.com/PaulGilmartin/django-queryhunter) +寻找 Django 应用程序代码中负责执行最多次查询的行。 + +[Lag-Llama](https://github.com/time-series-foundation-models/lag-llama) +面向概率时间序列预测的基础模型。 + +[HypoFuzz](https://github.com/Zac-HD/hypofuzz) +用于 Python 最佳测试工作流程的开源智能模糊测试。 + +[mwmbl](https://github.com/mwmbl/mwmbl) +一个用 Python 实现的开源、非盈利搜索引擎。 + +[instld](https://github.com/pomponchik/instld) +最简单的包管理。 + + + # 近期活动和网络研讨会 + +[PyLadies Dublin 2024 年 2 月聚会](https://www.meetup.com/pyladiesdublin/events/298929924/) +将会有一场演讲:当网络安全碰上 Python。 + +[Spokane Python 2024 年 2 月聚会](https://www.meetup.com/python-spokane/events/298213203/) +将会有一场演讲:介绍如何通过使用 PyO3 创建 Rust 绑定,从而将 Rust 集成到您的 Python 工作流程中。 + +[Python Barcelona 2024 年 2 月聚会](https://www.meetup.com/python-barcelona/events/299074873/) +将有以下演讲: + * Pytest,短途远足。 + * 《查询地图(Queering The Map)》的使用与话语分析 + + +[PyData Southampton 2024 年 2 月聚会](https://www.meetup.com/pydata-southampton/events/298595661/) +将有以下演讲: + * 将 3D 及以上的地理空间数据与 TileDB 数组相结合 + * 利用 GPU 计算搜索太空中的伽马射线源 + + +[PyData Berlin 2024 年 2 月聚会](https://www.meetup.com/pydata-berlin/events/298730602/) +将有以下演讲: + * 通过基于扩散的图神经网络利用数据结构和几何 + * 大型语言模型的采样策略示例 + + +[PyData Stockholm 2024 年 2 月聚会](https://www.meetup.com/pydatastockholm/events/299095628/) +将有以下演讲: + * 爬取 130 万条房价信息 —— 并且逃脱惩罚 + * BYOSC: + * 交通地图 + * DeLight - 延误航班预测器 + * 这张照片是在哪里拍摄的? - 深度学习时代的视觉地理定位。 diff --git a/Python Weekly/Python_Weekly_Issue_639.md b/Python Weekly/Python_Weekly_Issue_639.md new file mode 100644 index 0000000..c9ca3fd --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_639.md @@ -0,0 +1,96 @@ +原文:[Python Weekly - Issue 639](http://eepurl.com/iKyMsA) + +--- + +欢迎来到《Python周刊》第 639 期。让我们直奔主题。 + + +# 文章,教程和讲座 + +[让我们构建 GPT Tokenizer](https://www.youtube.com/watch?v=zduSFxRajkE) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +Tokenizer 对于大语言模型 (LLM) 至关重要,它在字符串和标记之间进行转换,作为一个具有单独训练集和算法的不同阶段运行。本讲座从头开始构建 GPT 系列 Tokenizer,揭示了 LLM 中与标记化相关的特殊行为。我们探讨这些问题,将其归因于标记化,并考虑完全消除此阶段的理想方案。” + +[在 Python 项目中安全使用凭证的 5 个技巧](https://www.youtube.com/watch?v=OOvvQRBcrhI) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +了解 5 个简单的技巧,以助于确保 Python 凭证安全,并在出现问题时快速解决问题. + +[从头开始构建一个 LLM](https://bclarkson-code.github.io/posts/llm-from-scratch-scalar-autograd/post.html) +了解如何完全从头开始构建一个具有所有花哨功能的现代语言模型:从普通 Python 到函数式编码助手。 + +[跟踪 Python 中的系统调用](https://blog.mattstuchlik.com/2024/02/16/counting-syscalls-in-python.html) +本文讨论了作者开发的一个添加到 Cirron 的工具,该工具使我们能够跟踪Python代码的系统调用。它提供了一个跟踪“print”函数的示例,并说明了该工具的实现,使用strace工具进行有效分析。文章还概述了使用 ptrace 系统调用进行实现的初衷,以及随后利用 strace 工具来处理复杂性。 + +[使用 IPython Jupyter Magic 命令改善 Notebook 体验](https://towardsdatascience.com/using-ipython-jupyter-magic-commands-to-improve-the-notebook-experience-f2c870cab356) +一篇关于创建自定义 IPython Jupyter Magic 命令的帖子。 + +[添加 Django 工作线程的最简单方法(使用 AWS Chalice)](https://www.photondesigner.com/articles/lambda-for-django) +本文讨论了如何利用 AWS Chalice 来合并 Django 工作线程,从而能够使用 lambda 函数作为任何应用程序的无服务器后台工作线程。这种方法允许 lambda 函数在后台运行,而不会阻塞应用程序的主线程,并且它可以在完成后调用 Django 应用程序上的端点,从而提供在 lambda 函数中使用任何 Python 库的能力,而无需引入 lambda 层或其他特定于 AWS 的配置。 + +[如何对一个使用了 Django、Preact 和 PostgreSQL 的应用程序进行 Docker 化](https://www.honeybadger.io/blog/dockerize-django-preact-postgres) +对 Django 应用程序进行 Docker 化可能是一件令人生畏的事情,但回报大于风险。在本指南中,Charlie Macnamara 将引导您完成这个设置过程,以便您可以充分利用您的应用程序。 + +[使用 Python 实现的算法艺术](https://www.youtube.com/watch?v=_XeRM-4DZz0) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在本次演讲中,我们将从零开始,构建我们自己的工具,用 Python 进行艺术创作,无需人工智能!我们将展示 Python 的表现力可以如何让我们优雅地描述图形,并使用它以编程方式制作一些独特的艺术作品。 + +[使用 Neon Postgres 和 AWS App Runner 部署任意规模的无服务器(Serverless) FastAPI 应用程序](https://neon.tech/blog/deploy-a-serverless-fastapi-app-with-neon-postgres-and-aws-app-runner-at-any-scale) +使用 FastAPI 创建无服务器 API,部署在 AWS App Runner 上并由 Neon Postgres 提供支持。 + + + # 好玩的项目,工具和库 + +[uv](https://github.com/astral-sh/uv) +一个非常快的 Python 包安装程序和解析器,用 Rust 编写。这是一篇详细介绍 uv 的[帖子](https://astral.sh/blog/uv)。 + +[OS-Copilot](https://github.com/OS-Copilot/FRIDAY) +一个自我改进的具体对话代理,无缝集成到操作系统中,以自动化我们的日常任务。 + +[Owl](https://github.com/OwlAIProject/Owl) +本地运行的个人可穿戴人工智能。 + +[Alto](https://github.com/runprism/alto) +面向数据从业者的 Serverless。在云中运行代码的最快方法。在虚拟机中轻松运行脚本、函数和 Jupyter Notebook。 + +[magika](https://github.com/google/magika) +通过深度学习检测文件内容类型。 + +[Streamline-Analyst](https://github.com/Wilson-ZheLin/Streamline-Analyst) +由 LLM 提供支持的人工智能代理,可简化数据分析的整个过程。 + +[minbpe](https://github.com/karpathy/minbpe) +LLM 标记化中常用的字节对编码 (Byte Pair Encoding,BPE) 算法的最小的干净代码。 + +[Hyperdiv](https://github.com/hyperdiv/hyperdiv) +使用 Python 构建响应式 Web UI。 + +[UFO](https://github.com/microsoft/UFO) +用于 Windows 操作系统交互的以 UI 为中心的代理。 + + +# 最新发布 + +[Python 3.13.0 alpha 4](https://pythoninsider.blogspot.com/2024/02/python-3130-alpha-4-is-now-available.html) + + +# 近期活动和网络研讨会 + +[Oxford Python 2024 年 2 月聚会](https://www.meetup.com/oxfordpython/events/299181384/) +将会有一场演讲:PyO3 入门。 + +[PyLadies Amsterdam 2024 年 2 月聚会](https://www.meetup.com/pyladiesams/events/298654058/) +将举办一个研讨会,微调文本到图像的扩散模型以实现个性化等。 + +[PyData Toronto 2024 年 2 月聚会](https://www.meetup.com/pydatato/events/298869004/) +将有以下演讲: + * 用于与 LLM 交互的数据文本处理 + * 因果推理:创建反事实,以及其在付费营销中的应用 + + +[PyData Lisbon 2024 年 2 月聚会](https://www.meetup.com/pydata-lisbon/events/299085332/) +将有以下演讲: + * 利用 Poetry 掌握 Python 项目 + * 生产中的 LLM,即 LLMOps + + +[PyData Prague 2024 年 2 月聚会](https://www.meetup.com/pydata-prague/events/298734567/) +将有以下演讲: + * 解锁效率 —— 矢量化的力量 + * Jupyter(Hub/Lab)——从本地到 AWS 之旅 diff --git a/Python Weekly/Python_Weekly_Issue_640.md b/Python Weekly/Python_Weekly_Issue_640.md new file mode 100644 index 0000000..7a15f7f --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_640.md @@ -0,0 +1,125 @@ +原文:[Python Weekly - Issue 640](http://eepurl.com/iK4M4-/) + +--- + +欢迎来到《Python周刊》第 640 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[生成人工智能完整课程 – Gemini Pro、OpenAI、Llama、Langchain、Pinecone、矢量数据库等](https://www.youtube.com/watch?v=mEsleV16qdo) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +了解生成式模型和不同的框架,研究人工智能生成的文本和视觉材料的生成。 + +[GPT Pilot —— 我们在CodeGen 结对程序员 GPT Pilot 上工作 6 个月期间,学到了什么](https://blog.pythagora.ai/2024/02/19/gpt-pilot-what-did-we-learn-in-6-months-of-working-on-a-codegen-pair-programmer/) +本文讨论了在 CodeGen 结对程序员 GPT Pilot 上工作 6 个月的经验教训,旨在让人类开发人员理解代码库,并详细解释了关于添加代码以促进人类开发人员和 AI 在编码任务中的协作。 + +[七分钟解释依赖注入](https://www.youtube.com/watch?v=DpMGEhwuuyA) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频解释了为什么依赖注入会改变您的编码项目的游戏规则。创建松散耦合的代码,是使代码更灵活、更可维护的关键。依赖关系的隐式使用使得这一切成为了可能。 + +[将 Mistral Large 部署到 Azure,并使用 Python 和 LangChain 创建对话](https://neon.tech/blog/deploy-mistral-large-to-azure-and-chat-with-langchain) +将 Mistral Large 部署到 Azure 的分步指南。 + +[requests 回顾](https://blog.ian.stapletoncordas.co/2024/02/a-retrospective-on-requests) +python-requests 已经存在很长时间了。而我已经担任它的维护者很多年了,我分享了一些对该项目的回顾性想法。 + +[Mamba:艰难之路](https://srush.github.io/annotated-mamba/hard.html) +一篇关于 Mamba 的文章,Mamba 是一种最新的神经架构,可以粗略地看作是一种现代循环神经网络 (RNN)。该模型的效果非常好,也是无处不在的 Transformer 架构的合法竞争对手。它已经引起了很多关注。 + +[为什么来自 R 的人会觉得 Pandas 笨重](https://www.sumsar.net/blog/pandas-feels-clunky-when-coming-from-r) +这篇文章讨论了从 R 过渡到 Python 中的 Pandas 的挑战和看法,探讨了习惯使用 R 的用户可能会觉得 Pandas 笨重的原因。作者提供了见解和技巧,以简化过渡过程并改进 Pandas 的使用体验。 + +[高级检索增强生成:从理论到 LlamaIndex 实现](https://towardsdatascience.com/advanced-retrieval-augmented-generation-from-theory-to-llamaindex-implementation-4de1464a9930) +如何通过在 Python 中实现有针对性的高级 RAG 技术,来解决原始 RAG 管道的局限性。 + +[使用 Mistral 7B 和 Ollama 构建一个打字助手](https://www.youtube.com/watch?v=IUTFrexghsQ) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在本 Python 教程中,我们将使用 Mistral 7B 和 Ollama 构建一个在本地运行的打字助手。您还将学习如何使用 Python 实现热键侦听器和键盘控制器。请按照此分步编码教程进行操作。 + +[使用 Python 的高级 Web 抓取:从任何站点提取数据](https://jacobpadilla.com/articles/advanced-web-scraping-techniques) +本文介绍了如何获取和管理 cookie 和自定义标头、避免 TLS 指纹识别、识别要发送请求的重要 HTTP 标头,以及如何实现指数退避的 HTTP 请求重试。 + +[在 5 分钟内构建检索增强一代聊天机器人](https://www.youtube.com/watch?v=N_OOfkEWcOk) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +NVIDIA 高级解决方案架构师 Rohan Rao 在 5 分钟内,仅用了 100 行 Python 代码,就演示了如何为 AI 聊天机器人应用程序开发和部署大型语言模型 (LLM),而无需使用您自己的 GPU 基础设施。 + +[Python 依赖项是可以修复的](https://matduggan.com/everyone-is-wrong-but-you/) +本文批评了 Python 依赖项管理的当前状态,强调需要更好的默认值和用户体验。与 Golang 的成功设计相似,作者主张 Pypa 生态系统内的心态转变,以改善 Pip 等工具的默认行为,并建议在必要时探索替代方案。 + + +# 好玩的项目,工具和库 + +[ingestr](https://github.com/bruin-data/ingestr) +ingestr 是一个 CLI 工具,可以使用单个命令在任何数据库之间无缝复制数据。 + +[ok-robot](https://github.com/ok-robot/ok-robot) +一个开放的模块化框架,用于在任意家庭中执行零样本、语言条件的拾取和放置任务。 + +[Evo](https://github.com/evo-design/evo) +从分子到基因组规模的 DNA 基础模型。 + +[AutoPrompt](https://github.com/Eladlev/AutoPrompt) +Auto Prompt 是一个 prompt 优化框架,旨在增强和完善现实世界用例的提示。 + +[PyRIT](https://github.com/Azure/PyRIT) +用于生成 AI 的 Python 风险识别工具 (PyRIT) 是一个开放访问的自动化框架,使安全专业人员和机器学习工程师能够主动发现他们的生成式 AI 系统中的风险。 + +[gemma_pytorch](https://github.com/google/gemma_pytorch) +Google Gemma 模型的官方 PyTorch 实现。 + +[justpath](https://github.com/epogrebnyak/justpath) +检查并优化 Windows 和 Linux 上的 PATH 环境变量。 + +[Mountaineer](https://github.com/piercefreeman/mountaineer) +Mountaineer 是一个包含开箱即用功能的 Python 和 React Web 框架。 + +[sqlbind](https://github.com/baverman/sqlbind) +基于文本的轻量级 SQL 参数绑定。 + +[hotpdf](https://github.com/weareprestatech/hotpdf) +hotpdf 是一个快速的 PDF 解析库,用于在 PDF 文档中提取文本并查找文本,在 pdfminer.six 之上构建。 + +[Sensei](https://github.com/migtissera/Sensei) +使用 OpenAI 或 MistralAI 生成合成数据。 + + +# 最新发布 + +[JupyterLab 4.1 和 Notebook 7.1 来咯](https://blog.jupyter.org/jupyterlab-4-1-and-notebook-7-1-are-here-20bfc3c10217) +JupyterLab 4.1 和 Notebook 7.1 现已推出!这些版本包括一些新功能、错误修复和扩展开发人员的增强功能。此版本兼容支持 JupyterLab 4.0 和 Notebook 7.0 的扩展。 + +[Visual Studio Code 中的 Python - 2024 年 3 月版](https://devblogs.microsoft.com/python/python-in-visual-studio-code-march-2024-release/) +此版本包括以下公告: +* 新添加导入代码操作启发式设置 +* 调试 Django 或 Flask 应用程序时,自动启动浏览器 +* Python REPL 的 Shell 集成 +* 对本地运行的 Jupyter 服务器的语言支持 + + +# 近期活动和网络研讨会 + +[PyData London 2024 年 3 月聚会](https://www.meetup.com/pydata-london-meetup/events/299219741/) +将有以下演讲: +* 构建单一事实来源:开发大规模实体解析系统 +* 人工智能的未来:开源 LLM + + +[IndyPy 2024 年 3 月聚会](https://www.meetup.com/indypy/events/298740418/) +将会有一场演讲:Eclipse Insights:人工智能如何改变太阳天文学。 + +[Python Milano 2024 年 3 月聚会](https://www.meetup.com/python-milano/events/299383407/) +将有以下演讲: +* Python 和 (棋盘)游戏设计 +* Python 和设计师 + + +[Cleveland PyLadies 2024 年 3 月聚会](https://www.meetup.com/cle-pyladies/events/298846189/) +将进行有关 Prompt 工程领域的讨论和学习。 + +[PyData Sudwest 2024 年 3 月聚会](https://www.meetup.com/pydata-suedwest/events/299017089/) +将有以下演讲: +* 超越 Parquet 的默认设置 – 您会得到令人惊讶的结果 - Uwe Korn +* 分析和优化模型预测服务 -Paolo Rechia + +[PyData Manchester 2024 年 3 月聚会](https://www.meetup.com/pydata-manchester/events/299463978/) +将会有一场演讲:开发有价值的 ML 产品。 + +[PyData Atlanta 2024 年 3 月聚会](https://www.meetup.com/pydata-atlanta/events/299285864/) +将会有一场演讲:释放商业应用中生成式 AI 的力量。 + \ No newline at end of file diff --git a/Python Weekly/Python_Weekly_Issue_641.md b/Python Weekly/Python_Weekly_Issue_641.md new file mode 100644 index 0000000..b3cbce9 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_641.md @@ -0,0 +1,132 @@ +原文:[Python Weekly - Issue 641](http://eepurl.com/iLzPwU) + +--- + +欢迎来到《Python周刊》第 641 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[Python 升级手册](https://eng.lyft.com/python-upgrade-playbook-1479145d52f4) +在这篇文章中,我们将介绍 Lyft 如何大规模升级 Python(涵盖 150 多个团队的 1500 多个存储库),以及我们为优化升级所需的总体时间以及我们工程师所需的工作而构建的工具和策略的最新迭代。我们通过多次升级(从 Python 2 到 Python 3.10)成功地使用(并改进)了这个手册。 + +[构建一个 LLM 微调数据集](https://www.youtube.com/watch?v=pCX_3p40Efc) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频分享了有关使用 Reddit 评论构建用于 AI 模型训练的综合数据集的见解,强调了诸如处理大型数据集和过滤掉低质量评论这样的挑战。作者讨论了加载、排序和过滤数据等方法来创建训练样本和模型,强调了可用于分析的注释样本丰富性以及微调模型以实现高效训练的过程。最终,他们决定使用 llama 27b 模型,并讨论利用 480 超级 GPU 更快地微调和上传数据集的计划。 + +[使用 Python 和 Grafana 实现更好的 PC 冷却](https://calbryant.uk/blog/better-pc-cooling-with-python/) +本文讨论了使用 Python 和 Grafana 改进 PC 冷却,关注于通过利用热质量并以经验得出的速度运行风扇,找到最小和最大风扇速度来优化冷却性能,从而提高冷却效率并降低冷噪音水平。 + +[使用 HTMX 和 Django,在六分钟内创建一个测验应用程序](https://www.photondesigner.com/articles/quiz-htmx) +本指南向您展示如何在 6 分钟内使用 Django 和 HTMX 创建一个简单的测验应用程序。HTMX 非常适合用来创建动态 Web 应用程序,无需编写 JavaScript。 + +[Django 中的多语言支持](https://medium.com/@sakhawy/multilingual-support-in-django-5706e1e144a8) +本文深入探讨了在 Django 中实现多语言支持的复杂性,探讨了国际化 (i18n) 和本地化所涉及的挑战和流程。它提供了有关 Django 如何促进字符串翻译、GNU gettext 框架的使用以及 Django 项目中支持多种语言的整体框架的见解。 + +[2024 年的机器学习 —— 新手课程](https://www.youtube.com/watch?v=bmmQA8A-yUA) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该机器学习课程是为 2024 年学习机器学习的初学者创建的。该课程从 2024 年机器学习路线图开始,强调职业道路和适合初学者的理论。然后,课程将转向实际应用和使用 Python 的综合端到端项目。 + +[DSPy 简介:再见 Prompting,你好 Programming!](https://towardsdatascience.com/intro-to-dspy-goodbye-prompting-hello-programming-4ca1c6ce3eb9) +DSPy 框架是如何通过用编程和编译代替提示,来解决基于 LLM 的应用程序中的脆弱性问题的。 + +[处理一个 CSV 文件能有多快](https://datapythonista.me/blog/how-fast-can-we-process-a-csv-file) +本文探讨了处理 CSV 文件的速度,重点介绍了如何使用 PyArrow 来显着提高 CSV 读取速度。它比较了来自使用 C 引擎的 pandas、纯 Python 循环以及使用 PyArrow 引擎的 pandas 的不同方法,展示了 PyArrow 在更快、更有效地处理 CSV 文件方面的效率。 + +[复杂度级别:RAG 应用](https://jxnl.github.io/blog/writing/2024/02/28/levels-of-complexity-rag-applications) +这篇文章是一个综合指南,用以理解和实现不同复杂程度下的 RAG 应用程序。无论您是渴望学习基础知识的初学者,还是希望加深专业知识的经验丰富的开发人员,您都会找到宝贵的见解和实践知识来帮助您完成您的旅程。让我们一起开始这一激动人心的探索,释放 RAG 应用程序的全部潜力吧。 + +[将 Rust 和 Python 组合在一起:两全其美?](https://www.youtube.com/watch?v=lyG6AKzu4ew) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频向您展示如何使用 Pyo3 将 Rust 与 Python 无缝集成在一起。该库允许您使用 Rust 编写 Python 模块。这意味着我们同时可以获得 Rust 的速度和安全性以及 Python 易于使用的功能! + +[在 Kubernetes 中部署 Django 应用](https://blog.jetbrains.com/pycharm/2024/03/deploying-django-apps-in-kubernetes/) +了解无论您是 Django 开发人员还是 Kubernetes 爱好者,您都可以在 Kubernetes 环境中无缝优化 Django 部署。 + +[conda 环境入门](https://www.dataschool.io/intro-to-conda-environments/) +这篇文章解释了虚拟环境的好处,以及如何在 conda 中使用虚拟环境。 + +[从 Beeps 到 Toots:用 Python 和 Mastodon 复兴寻呼机](https://finnley.dolphinhome.net/2024/02/25/from-beeps-to-toots-reviving-pagers-with-python-and-mastodon/) +本文展示了 Python 编程的一个独特应用,将寻呼机与 Mastodon 连接起来,将寻呼机的可靠性与现代社交媒体交互融为一体。它强调了 Python 在桥接寻呼机等模拟设备与数字平台方面的多功能性,展示了传统通信方法在当今数字时代的持久相关性。 + +[使用 JupyterLab Desktop CLI 进行 Python 环境管理](https://blog.jupyter.org/python-environment-management-using-jupyterlab-desktop-cli-e57485c9287c) +这篇文章讨论了使用 JupyterLab Desktop CLI 进行 Python 环境管理的方法,该工具提供了各种命令和选项,以便在应用程序内有效地管理 Python 环境。其内容涵盖了设置 JupyterLab Desktop CLI、创建新的 Python 环境以及利用捆绑的环境安装程序或从注册中心下载软件包来增强开发过程。 + +[改善你的 Python 项目架构的六种方式(使用 import-linter)](https://www.piglei.com/articles/en-6-ways-to-improve-the-arch-of-you-py-project/) + +这篇文章讨论了六种增强Python项目架构的方法,重点是维护包和模块之间清晰的依赖关系,以避免纠缠在一起的模块间依赖。它解决了像新手对高架构的理解成本,以及在大型项目中难以定位代码导致开发效率降低这样的挑战。 + + +# 好玩的项目,工具和库 + +[Hatchet](https://github.com/hatchet-dev/hatchet) +一个分布式、容错的任务队列。 + +[BlendSQL](https://github.com/parkervg/blendsql) +统一的语言,用于协调 SQLite 逻辑和 LLM 推理。 + +[django-admin-shellx](https://github.com/adinhodovic/django-admin-shellx) +一个使用 Xterm.js 和 Django Channels 的 Django 管理后台 Web Shell。 + +[Bonito](https://github.com/BatsResearch/bonito) +一个轻量级的库,用于为您的数据生成合成的指令调整数据集,无需使用 GPT。 + +[FastUI](https://github.com/pydantic/FastUI) +更快更好的构建 UI。 + +[Hancho](https://github.com/aappleby/hancho) +一个简单而愉快的构建系统,用 Python 编写。 + +[Cadwyn](https://github.com/zmievsa/cadwyn) +生产就绪的、由社区驱动的、现代的类似于Stripe的API,在 FastAPI 框架中对此 API 进行版本管理和控制。 + +[flect](https://github.com/Chaoyingz/flect) +受 Next.js 启发的纯 Python 全栈 Web 应用程序框架。 + +[pfl](https://github.com/apple/pfl-research) +用于私有联合学习模拟的 Python 框架。 + +[EvalPlus](https://github.com/evalplus/evalplus) +EvalPlus 用于对 LLM 合成代码进行严格评估。 + +[polars_ds_extension](https://github.com/abstractqqq/polars_ds_extension) +适用于一般数据科学用例的 Polars 扩展。 + + +# 最新发布 + +[Django 安全版本已发布:5.0.3,4.2.11 和 3.2.25](https://www.djangoproject.com/weblog/2024/mar/04/security-releases/) + + + # 近期活动和网络研讨会 + +[San Francisco Python 2024 年 3 月聚会](https://www.meetup.com/sfpython/events/297988890/) +将会有以下演讲: +* 电子表格有什么作用?!? +* 非结构化:LLM的 ETL +* 数据管道记分卡 +* 帮助开发者自助 + +[Django London 2024 年 3 月聚会](https://www.meetup.com/djangolondon/events/299189999/) +将会有以下演讲: +* WASM 支持的 Django 应用程序,使用 PyScript +* 2024 年求职指南 + +[PuPPy 2024 年 3 月聚会](https://www.meetup.com/psppython/events/299203397/) +将会有以下演讲: +* 在量子计算机上模拟 3 偏振器实验 +* 为什么我喜欢计划,你也应该如此! +* 上升的海(The Rising Sea) + + +[Virtual: PyMNtos Python 演示之夜 #123](https://www.meetup.com/pymntos-twin-cities-python-user-group/events/299328386/) +将会有以下演讲: +* 关于《Python 简介》第三版的想法 +* 使用 CLIP 进行多模态图像搜索 + +[PyData NYC 2024 年 3 月聚会](https://www.meetup.com/pydatanyc/events/299507856/) +将会有以下演讲: +* 在生产中构建LLM应用程序 +* 但是,您对超参数的调整够了吗? + +[PyData Johannesburg 2024 年 3 月聚会](https://www.meetup.com/pydata-johannesburg/events/299175850/) +将会有一场演讲:揭秘 Apache Nifi 的数据摄取挑战。 + +[PyData Zurich 2024 年 3 月聚会](https://www.meetup.com/pydata-zurich/events/298797804/) +将会有一场演讲:基于注意力的自回归模型的多功能性。 diff --git a/Python Weekly/Python_Weekly_Issue_642.md b/Python Weekly/Python_Weekly_Issue_642.md new file mode 100644 index 0000000..1127f18 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_642.md @@ -0,0 +1,134 @@ +原文:[Python Weekly - Issue 642](http://eepurl.com/iL4r1k) + +--- + +欢迎来到《Python周刊》第 642 期。让我们直奔主题。 + + +# 新闻 + +[DjangoCon US 2024 CFP](https://pretalx.com/djangocon-us-2024/cfp) +DjangoCon US 2024 CFP 现已开放。请在美国东部时间 2024 年 4 月 24 日中午 12 点之前提交您的演讲或教程提案。 + + +# 文章,教程和讲座 + +[为了50,000美元,我们黑进了谷歌A.I.](https://www.landh.tech/blog/20240304-google-hack-50000) +这篇文章讨论了作者参加拉斯维加斯的一个黑客活动的经历,在活动中他们发现了漏洞,从而成功黑进了谷歌。尽管最初取得了成就,但谷歌VRP团队延长了比赛截止日期,以鼓励更多创造性的发现,突显了网络安全领域不断面临的挑战和机遇。 + +[为什么说在 2024 年你应该使用 Pydantic](https://www.youtube.com/watch?v=502XOB0u8OY) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在这个更新的Pydantic教程中,我将介绍所有新功能及其给项目带来的好处。尽管Python的动态类型系统是用户友好的,但它并非没有数据处理问题。这就是Pydantic发挥作用的地方,它为无缝数据管理提供了必要的结构和验证。 + +[GGUF,迂回的长途](https://vickiboykis.com/2024/02/28/gguf-the-long-way-around/) +这是一篇关于GGUF的文章,它是一种用于机器学习模型的文件格式。文章讨论了什么是机器学习模型以及它们是如何生成的。 + +[实践中的Python Gevent:需要牢记的常见陷阱](https://upsun.com/blog/python-gevent-best-practices/) +在这篇文章中,了解使用异步Python库Gevent的常见陷阱,以及如何解决这些问题。 + +[使用Collectfasta加速Django的collectstatic命令](https://jasongi.com/2024/03/04/speed-up-djangos-collectstatic-command-with-collectfasta/) +这篇文章介绍了Collectfasta,这是Collectfast的更新版本,旨在提高Django的collectstatic命令的性能。通过优化存储库并提高性能,Collectfasta提供了比标准Django命令更快的执行和效率,为寻求提高Django项目性能的开发人员提供了有价值的工具。 + +[创建一个基于机器学习的NCAA比赛预测模型](https://www.youtube.com/watch?v=cHtAEWkvSMU) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +深入探讨机器学习和人工智能的迷人世界,我们将指导您开发一个旨在预测NCAA锦标赛结果的模型。从初始设置到最终预测,我们将覆盖您创建自己强大模型所需的一切内容。 + +[使用Win32 App隔离为Python创建沙箱环境](https://blogs.windows.com/windowsdeveloper/2024/03/06/sandboxing-python-with-win32-app-isolation/) +这篇文章探讨了为Python中创建沙箱环境的挑战和好处,特别是在网站执行用户代码或防止针对大型语言模型的攻击等情况下。Win32 App隔离提供了一种在应用程序/操作系统级别隔离Python的独特方法,它创建了一个安全边界来防止应用程序破坏操作系统。 + +[使用LLMs生成模糊生成器的](https://verse.systems/blog/post/2024-03-09-using-llms-to-generate-fuzz-generators) +这篇文章探讨了大型语言模型(LLMs)在生成库API模糊驱动程序方面的有效性。它讨论了基于LLM的模糊驱动程序生成的挑战和好处,突出了其实用性、复杂API使用的策略以及基于全面研究和评估的改进方向。 + +[Python中的时间序列分析指南](https://www.timescale.com/blog/how-to-work-with-time-series-in-python/) +探讨了 Python 为何是进行时间序列分析的好语言。另外,还有一些入门建议。 + +[使用MediaPipe和TensorFlow Lite在设备上进行的大型语言模型](https://developers.googleblog.com/2024/03/running-large-language-models-on-device-with-mediapipe-andtensorflow-lite.html) +文章讨论了实验性的MediaPipe LLM推理API的发布,该API使大型语言模型(LLMs)能够完全在设备上跨平台运行。这一变革性功能解决了LLMs的显著内存和计算需求,这些需求是传统设备上模型的100多倍,通过新的运算、量化、缓存和权重共享等优化实现。 + +[Homebrew 所有 Python 的东西](https://blog.davep.org/2024/03/10/homebrew-all-the-python-things.html) + +[不安全感和 Python 对象序列化](https://lwn.net/SubscriberLink/964392/498a12fe44f51139/) + +[理解上下文管理器及其语法糖](https://bjoernricks.github.io/posts/python/context-manager/) + +[Python 有指针嘛?](https://nedbatchelder.com/blog/202403/does_python_have_pointers.html) + + + # 好玩的项目,工具和库 + +[openllmetry](https://github.com/traceloop/openllmetry) +LLM 申请的开源可观察性。 + +[CBScript](https://github.com/SethBling/cbscript) +CBScript 是一种转译语言,由 SethBling 设计。该编译器会将 CBScript 文件编译为 Minecraft 数据包 zip 文件。它具有许多 Minecraft 命令级别所不存在的高级语言功能。 + +[SQLMesh](https://github.com/TobikoData/sqlmesh) +向后兼容 dbt 的高效数据转换和建模框架。 + +[Dataverse](https://github.com/UpstageAI/dataverse) +数据宇宙。关于数据、数据科学和数据工程。 + +[LlamaGym](https://github.com/KhoomeiK/LlamaGym) +利用在线强化学习微调 LLM 代理。 + +[chedule-texts-from-txt](https://github.com/reidjs/schedule-texts-from-txt) +根据 .txt 文件安排 iMessage 或 SMS 文本。 + +[fructose](https://github.com/bananaml/fructose) +像调用强类型函数那样调用 LLM。 + +[R2R](https://github.com/SciPhi-AI/R2R) +快速开发和部署生产可用的 RAG 系统的框架。 + +[python-docstring-highlighter](https://github.com/rodolphebarbanneau/python-docstring-highlighter) +VSCode 中 Python 文档字符串的语法高亮显示。 + +[Ludic](https://github.com/paveldedik/ludic) +纯 Python 方式构建 HTML 页面的轻量级框架。 + + + +# 最新发布 + +[Python 3.13.0 alpha 5 现已发布](https://pythoninsider.blogspot.com/2024/03/python-3130-alpha-5-is-now-available.html) + + +# 近期活动和网络研讨会 + +[PyLadies London 2024 年 3 月聚会](https://www.meetup.com/pyladieslondon/events/299658808/) +将会有以下演讲: + * 指导职业道路决策 + * Spotify 是如何通过机器学习个性化您的搜索结果的 + + +[Python Barcelona 2024 年 3 月聚会](https://www.meetup.com/python-barcelona/events/299261127/) +将会有以下演讲: + * Python 和 Rust + * 动手操作 Polars,Rust 中数据框架的替代方案 + + +[BayPIGgies 2024 年 3 月聚会](https://www.meetup.com/baypiggies/events/299305900/) +将会有以下演讲: + * SRE 的趣味世界 + * 更好地结合起来:释放 Pandas、Polars 和 Apache Arrow 的协同作用 + * 模拟直到成功:如何在不离开单元测试的情况下验证您的外部模拟 + + +[PyData Stockholm 2024 年 3 月聚会](https://www.meetup.com/pydatastockholm/events/299375069/) +将会有以下演讲: + * 微调您自己的 Stable Diffusion 模型 - 包括提示和技巧 + * 实际应用中的人工智能工具:Polestar 是如何利用 LLM 增强客户体验的 + + +[PyData Southampton 2024 年 3 月聚会](https://www.meetup.com/pydata-southampton/events/298930338/) +将会有以下演讲: + * Python 支持的现代数据堆栈 + * 讲透 Transformer + * 使用脑电图评估认知工作量 + * 时间序列数据库基准测试 + +[PyData Ireland 2024 年 3 月聚会](https://www.meetup.com/pydataireland/events/299173763/) +将会有一场演讲:生成式人工智能企业格局——过去、现在和未来。 + +[PyData Paris 2024 年 3 月聚会](https://www.meetup.com/pydata-paris/events/299457555/) +将会有以下演讲: + * 仅用 Python,将你的数据项目部署在网上 + * 充分利用 scikit-learn 分类器:可信概率和最优二元决策 diff --git a/Python Weekly/Python_Weekly_Issue_643.md b/Python Weekly/Python_Weekly_Issue_643.md new file mode 100644 index 0000000..12fd777 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_643.md @@ -0,0 +1,123 @@ +原文:[Python Weekly - Issue 643](http://eepurl.com/iMv32k) + +--- + +欢迎来到《Python周刊》第 643 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[如何使用 PostgreSQL 执行(军事)地理分析任务](https://klioba.com/how-to-use-postgresql-for-military-geoanalytics-tasks) +这是一个关于利用 PostgreSQL 进行军事地理分析任务的详细指南,强调了地理空间数据处理在军事行动中的重要性。它涵盖了地理空间数据处理、最近物体查找、距离计算、地理空间索引的使用、多边形内的点的确定以及地理空间聚合的方法,以增强军事环境中的分析能力。 + +[Python 中的每个 dunder 方法](https://www.pythonmorsels.com/every-dunder-method/) +对 Pytho 所有的 100 多种 dunder 方法和 50 多种 dunder 属性的解释,包括每一种的摘要。 + +[地狱模式下的 Lambda:走进 Modal 的 web 基础架构](https://modal.com/blog/serverless-http) +这篇文章讨论了 Modal 是如何在无服务器函数中处理实时 HTTP 请求和 WebSocket 的 + +[如何测试 Python 中的异步代码?](https://www.youtube.com/watch?v=n1nqgMtWRwg) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +异步代码测试是很棘手的,但对于创建流畅、无错误且可靠的应用程序却是至关重要。因此,在本视频中,我将指导您了解有效测试异步代码的基础知识。 + +[Pixi 的多种环境介绍](https://prefix.dev/blog/introducing_multi_env_pixi) +这篇文章介绍了 Pixi 的多环境功能,允许用户为不同的任务(如测试、开发或生产)创建具有特定包集的定制环境。 Pixi 中的这一增强功能使用户能够根据项目需求自定义环境,从而在管理依赖项和任务方面提供灵活性和效率。 + +[从新理论的角度,从头开始介绍扩散模型](https://www.chenyang.co/diffusion.html) +本文提供了使用欧几里得距离函数解释和增强扩散模型的见解,详细探讨了扩散模型及其应用。它专注于通过梯度估计、高效采样技术以及可视化动量项对文本到图像生成的影响来改进扩散模型。 + +[用 Python 构建命令行应用](https://www.honeybadger.io/blog/building-command-line-applications-in-python-a-comprehensive-guide/) +深入了解如何在 Python 中实现命令行应用程序。本教程构建了一个 BMI 计算器应用程序并在 Python 中实现 Linux head 命令,并使用 argparse 模块来解释参数、标志和选项是如何在命令行应用程序中工作的。 + +[Nextjs 和 Django Airbnb 克隆](https://www.youtube.com/playlist?list=PLpyspNLjzwBnP-906FBRP5qzB4YXjMvnT) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +了解如何构建 Airbnb 的全栈克隆,其中,前端使用 Nextjs/React 和 Tailwind 等技术,后端使用 Django 和 Django Rest 框架。 + +[让您的 Pandas 或 Polars DataFrame 与 ITables 2.0 进行交互](https://blog.jupyter.org/make-your-pandas-or-polars-dataframes-interactive-with-itables-2-0-c64e75468fe6) +ITables(或交互式表)是一个 MIT 许可的 Python 包,它使用 DataTables JavaScript 库呈现 Python DataFrames。我刚刚发布的 ITables 2.0 中添加了对 DataTables 扩展的支持。在这篇文章中,我们回顾了此版本带来的功能。 + +[用计算机视觉对我的黑胶唱片收藏进行编目](https://jamesg.blog/2024/03/16/vinyl-record-indexing/) +这篇文章详细介绍了使用计算机视觉对黑胶唱片收藏进行编目的过程,重点是通过系统方法识别独特的黑胶唱片。通过利用计算机视觉技术和嵌入技术,作者分享了关于创建一个系统的见解,这个系统可以准确识别和索引黑胶唱片,以实现高效的编目和组织。 + +[AutoDev:自动化 AI 驱动开发(Automated AI-Driven Development)](https://arxiv.org/html/2403.08299v1) +论文“AutoDev:自动化人工智能驱动开发(AutoDev: Automated AI-Driven Development)”提出了一种人工智能驱动开发的自动化方法,涉及多位作者的协作努力。它探讨了人工智能驱动的自动化开发流程的进步,展示了对 AutoDev 的全面研究 + +[在 Python 中解析 URL](https://tkte.ch/articles/2024/03/15/parsing-urls-in-python.html) +本文深入探讨了用 Python 解析 URL 的复杂性,重点介绍了 URL 规范随着时间的推移所面临的挑战和演变。它强调了把 WHATWG URL 规范当成在 Python 应用程序中准确处理 URL 的可靠指南的重要性。 + +[Jupyter 与 IPython 术语解释](https://www.dataschool.io/jupyter-and-ipython-terminology/) +了解 Jupyter Notebook、JupyterLab、IPython、Colab 和其他相关术语之间的差异。 + + +# 好玩的项目,工具和库 + +[Grok-1](https://github.com/xai-org/grok-1) +Grok 开源版本。 + +[Skyvern](https://github.com/Skyvern-AI/skyvern) +通过 LLM 和计算机视觉自动化基于浏览器的工作流程。 + +[MindGraph](https://github.com/yoheinakajima/mindgraph) +用于使用 AI 生成和查询不断扩展的知识图的概念原型验证。 + +[Chronos](https://github.com/amazon-science/chronos-forecasting) +用于概率时间序列预测的预训练(语言)模型。 + +[LaVague](https://github.com/lavague-ai/LaVague) +使用大型动作模型框架实现自动化。 + +[DarkGPT](https://github.com/luijait/DarkGPT) +DarkGPT是一款基于GPT-4-200K的人工智能助手,旨在对泄露的数据库执行查询。 + +[phospho](https://github.com/phospho-app/phospho) +LLM 应用程序的文本分析。PostHog 获取提示。从短信中提取评价、意图和事件。 phosph 利用 LLM(OpenAI、MistralAI、Ollama 等) + +[LLM4Decompile](https://github.com/albertan017/LLM4Decompile) +逆向工程:使用大型语言模型反编译二进制代码。 + +[sqlelf](https://github.com/fzakaria/sqlelf) +通过 SQL 的强大功能来探索 ELF 对象。 + +[Magix](https://github.com/luyug/magix) +通过模型并行性增强拥抱面 transformer。 + + +# 最新发布 + +[Django REST 框架 3.15](https://www.django-rest-framework.org/community/3.15-announcement/) + +[Python 3.10.14、3.9.19 和 3.8.19 现已发布](https://pythoninsider.blogspot.com/2024/03/python-31014-3919-and-3819-is-now.html) + + +# 近期活动和网络研讨会 + +[Virtual: PyMunich 2024 年 3 月聚会](https://www.meetup.com/pymunich/events/299459088/) +将会有以下演讲: + * 一次利用 Python 异步和线程的操作系统之旅 + * 无服务器应用程序的干净架构 + + +[Virtual: DragonPy 2024 年 3 月聚会](https://www.meetup.com/ljubljana-python-group/events/299732452/) +将会有以下演讲: + * Apache Arrow - 管理字节以获得乐趣和利润 + * 自托管数据堆栈 + * SQL 和 Python:数据仓库的动态组合 + + +[San Diego Python 2024 年 3 月聚会](https://www.meetup.com/pythonsd/events/299374271/) +将会有以下演讲: + * RWKV:transformer 的继承者? + * 使用 LangChain 来构建 AI 应用 + * 在 Cloudera 数据工程中使用 Apache Sedona + + +[PyData Cyprus 2024 年 3 月聚会](https://www.meetup.com/pydata-cyprus/events/299459091/) +将会有一场演讲:大型语言模型之旅。 + +[PyData Montreal 2024 年 3 月聚会](https://www.meetup.com/pydata-mtl/events/299605178/) +将会有以下演讲: + * 机器学习可以如何帮助游戏设计 + * BigCode:开放且负责任的大型代码语言模型开发 + + +[PyData Bristol 2024 年 3 月聚会](https://www.meetup.com/pydata-bristol/events/299738605/) +将会有以下演讲: + * 无声入侵:LLM是如何渗透企业的 + * 用数据科学赋能社会:对日常产生影响的快速部署策略 diff --git a/Python Weekly/Python_Weekly_Issue_644.md b/Python Weekly/Python_Weekly_Issue_644.md new file mode 100644 index 0000000..c69d389 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_644.md @@ -0,0 +1,108 @@ +原文:[Python Weekly - Issue 644](http://eepurl.com/iMZAHE) + +--- + +欢迎来到《Python周刊》第 644 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[设计一个纯 Python Web 框架](https://reflex.dev/blog/2024-03-21-reflex-architecture/) +本文解释了Reflex(一个纯 Python 的 Web 框架),是如何让用户可以在无需学习新语言的情况下构建网络应用的。它详细介绍了 Reflex 都工作原理,重点介绍了其将 UI 编译为 JavaScript 的独特方法,同时在服务器上使用 Python 保留应用程序逻辑和状态管理。 + +[修复 PyPy 增量垃圾收集器中的一个错误](https://www.pypy.org/posts/2024/03/fixing-bug-incremental-gc.html) +本文讨论了作者是如何修复 PyPy 增量垃圾收集器中的一个错误的,这个错误在 CI 环境中 pytest 的 AST 重写阶段会导致崩溃。它详细介绍了 PyPy 增量 GC 的技术背景,以及在写屏障实现中发现和解决的具体问题。 + +[针对执行速度慢的函数调用的一个更好的 Python 缓存](https://docs.sweep.dev/blogs/file-cache) +本文介绍了一种 Python 文件缓存,它将函数值存储在文件中而不是存储在内存中,从而提供了更持久的缓存解决方案。通过使用 file_cache 装饰器,开发人员可以节省运行 LLM 基准测试等函数的时间并将缓存作为 Python 的模块共享,从而提高性能。 + +[Django:关于优化系统检查框架的文章](https://adamj.eu/tech/2024/03/23/django-optimizing-system-checks/) +这篇文章讨论了对 Django 系统检查框架的优化,该框架因速度慢而闻名。这些优化将在示例客户端项目上的检查操作运行时间从 37 毫秒减少到 18 毫秒,共减少了 50%。 + +[八分钟 Python Poetry](https://www.youtube.com/watch?v=Ji2XDxmXSOM) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频将指导您歇息管理 Python 虚拟环境的方方面面,同时还向您介绍了 Poetry。您将学习大量技巧和策略,以更有效地管理您的项目。 + +[伪造短信:兔子洞到底有多深?](https://medium.com/@aleksamajkic/fake-sms-how-deep-does-the-rabbit-hole-really-go-17e25c42f986) +通过模糊的恶意软件代码迷宫追踪不良行为者。 + +[使用 Numba 加速代码的错误方式](https://pythonspeed.com/articles/slow-numba/) +Numba 可以使您的数字代码更快,但前提是您正确使用它。 + +[不必要的 else 语句](https://www.pythonmorsels.com/unnecessary-else-statements/) +让我们来谈谈 Python 中不必要的 else 语句。 + +[使用 Apache Superset 和 PostgreSQL 实现数据可视化](https://www.timescale.com/blog/data-visualization-in-postgresql-with-apache-superset/) +正在寻找适用于 PostgreSQL 的数据可视化工具吗?我们讨论了一些选项,并提供了有关 PostgreSQL 和 Apache Superset 的分步指南。 + +[为移动开发人员构建 Django API](https://www.youtube.com/playlist?list=PLgRx2Eap1Wm2W-ozbwAZwffEwTTy8xS5g) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +深入了解应用程序开发的后端,重点关注使用 Django 和 Django Rest Framework 来构建强大的 API。 + +[安全的 LLM 架构 —— 测试 LLM Guard](https://www.youtube.com/watch?&v=C_5KRqQrGD4) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频探讨了 LLM 架构,解决了安全问题并批评了无效的安全工具。它介绍了 LLM Guard,这是一种开源工具,旨在通过检查输入是否存在恶意意图和输出是否敏感数据来增强 LLM 的安全性,并通过实际示例对其进行了演示,还强调输出监控和权限在保护数据方面的重要性。 + +[谓词下推(predicate pushdown)的威力](https://pola.rs/posts/predicate-pushdown-query-optimizer/) +谓词下推(Predicate pushdown)是查询引擎最重要的优化之一。通过本文了解更多相关信息。 + +[带原生 Python 扩展和 Dispatch 的分布式协程](https://stealthrocket.tech/blog/distributed-coroutines-in-python/) +本文讨论了分布式协程是如何与 Dispatch 等分布式调度程序配合使用的,从而通过允许函数在另一个进程中挂起、序列化和恢复来简化可扩展且可靠的软件的创建。它重点介绍了分布式协程如何利用 Python 对协程和异步函数的原生支持,使用常规编程语言结构和控制流对动态工作流程进行编码。 + +[AWS Lambda + Bedrock 教程](https://www.youtube.com/watch?v=vQ9BUc-UmXY) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +了解如何使用 AWS Lambda 从 AWS Bedrock 调用 API。本视频手把手教您使用Python和boto3的Bedrock客户端调用InvokeModel API。它还向您展示设置 IAM 权限并修改 Lambda 超时值以应对 Bedrock 的缓慢响应的方法。 + + +# 好玩的项目,工具和库 + +[open-interpreter](https://github.com/OpenInterpreter/open-interpreter) +计算机自然语言界面。 + +[Devika](https://github.com/stitionai/devika) +Agentic 人工智能软件工程师。 Devika 的目标是成为 Cognition AI 开发的 Devin 的有竞争力的开源替代品。 + +[T-Rex](https://github.com/IDEA-Research/T-Rex) +通过文本-视觉提示协同,实现通用物体检测。 + +[OpenDevin](https://github.com/OpenDevin/OpenDevin) +一个旨在复制 Devin 的开源项目,Devin 是一位自主人工智能软件工程师,能够执行复杂的工程任务并在软件开发项目上与用户积极协作。 + +[VoiceCraft](https://github.com/jasonppy/VoiceCraft) +零次语音编辑和文本转语音。 + +[lightning-thunder](https://github.com/Lightning-AI/lightning-thunder) +让 PyTorch 模型快如闪电! Thunder 是一个针对 PyTorch 的源到源编译器。它允许同时使用不同的硬件执行器。 + + +[reverser_ai](https://github.com/mrphrazer/reverser_ai) +过在消费类硬件上使用本地大语言模型 (LLM),提供自动化逆向工程协助。 + +[Leaping](https://github.com/leapingio/leaping) +Leaping 的 pytest 调试器是一个简单、快速、轻量级的 Python 测试调试器。 Leaping 跟踪代码的执行,并允许您使用基于 LLM 的自然语言调试器,随时追溯检查程序的状态。 + +[Tracecat](https://github.com/TracecatHQ/tracecat) +Tines / Splunk SOAR 的 AI 原生开源替代品。 + +[rag-search](https://github.com/thinkany-ai/rag-search) +RAG 搜索 API。 + +[FeatUp](https://mhamilton.net/featup.html) +一个与模型无关的框架,适用于任何分辨率的特征。 + + +# 近期活动和网络研讨会 + +[PyData London 2024 年 4 月聚会](https://www.meetup.com/pydata-london-meetup/events/299970694/) +将会有以下演讲: + * 构建检索增强生成 (RAG) 支持的应用程序 + * 将 ML 模型从研究转移到生产时,让 Python 成为一种可能。深入探讨开放神经网络交换 (ONNX) + +[Michigan Python 2024 年 4 月聚会](https://www.meetup.com/michigan-python/events/299683479/) +将会有一场演讲:使用 GeoPandas 对空间数据进行可视化。 + +[PyData Amsterdam 2024 年 4 月聚会](https://www.meetup.com/pydata-nl/events/299967889/) +将会有以下演讲: + * 欺诈与否:听起来很简单,对吧? + * 使用 OSS Metaflow 构建 GenAI 和 ML 系统 + +[PyData Tel Aviv 2024 年 4 月聚会](https://www.meetup.com/pydata-tel-aviv/events/299310820/) +将会有以下演讲: + * 投标还是不投标 —— 针对实时投标的强化学习 + * 使用 Rebuff 保护 LangChain 应用程序以免受即时注入 + * Polars是Pandas杀手 diff --git a/Python Weekly/Python_Weekly_Issue_645.md b/Python Weekly/Python_Weekly_Issue_645.md new file mode 100644 index 0000000..9c4e068 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_645.md @@ -0,0 +1,114 @@ +原文:[Python Weekly - Issue 645](http://eepurl.com/iNp38k) + +--- + +欢迎来到《Python周刊》第 645 期。让我们直奔主题。 + +# 新闻 + +[针对 Python 开发人员的域名仿冒运动](https://blog.phylum.io/typosquatting-campaign-targets-python-developers/) + +Phylum 的自动风险检测平台发现了一场针对 PyPI 上流行 Python 库的新域名仿冒运动,迄今为止已发布了 500 多个域名仿冒变体。 PyPI 已立即删除恶意软件包,并暂时停止新项目和帐户创建,以防止此次攻击造成进一步影响。 + + +# 文章,教程和讲座 + +[关于在 2024 年构建大型语言模型的一个小指南](https://www.youtube.com/watch?v=2-SPH9hIKT8) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +这是两部分系列的第一个视频,涵盖了在 2024 年训练具备良好性能 LLM 的所有概念。 + +[为什么 Python 列表会奇怪地倍增?探索 CPython 源代码](https://codeconfessions.substack.com/p/why-do-python-lists-multiply-oddly) +看看 CPython 中列表实现的内部结构,以了解它们的这个怪癖。 + +[使用 Pyodide 和 WebAssembly,为 Python 引入 Workers](https://blog.cloudflare.com/python-workers) +这篇文章讨论了 Cloudflare 对 Python Workers 的实现,重点介绍了它们在无服务器计算方面的优势和用例。它探讨了 Python Workers 如何帮助开发人员在 Cloudflare 网络上高效构建和部署轻量级、可扩展的应用程序。 + +[制作(Make)Python DevEx](https://tech.target.com/blog/make-python-devex) +本文讨论了建立高效的 Python 开发环境的挑战,以及如何使用 Make 通过自动准备开发环境和加快测试驱动的开发周期来帮助缓解这些障碍。作者提供了一个示例项目,演示如何使用 Make 改善跨多个代码库的 Python 开发人员体验。 + +[通过内省,在 Django 项目中强制执行约定](https://lukeplant.me.uk/blog/posts/enforcing-conventions-in-django-projects-with-introspection/) +结合 Python 和 Django 内省 API,在 Django 模型中强制执行命名约定的一些代码和技巧。 + +[构建用于代码修复的 LLM](https://blog.replit.com/code-repair) +本文讨论了 Replit 的代码修复功能,该功能可自动修复代码中的常见编程错误和问题。它探讨了通过为常见编码问题提供自动化解决方案,代码修复可以如何帮助开发人员节省时间并提高代码质量。 + +[利用断点探索代码](https://www.mostlypython.com/using-breakpoints-to-explore-your-code/) +本文指导 Python 开发人员有效利用断点来调试和探索代码执行流程。它提供了关于利用断点来更好地理解 Python 代码并进行故障排除的实用技巧和示例。 + +[Django 的 ASGI 部署选项](https://fly.io/django-beats/asgi-deployment-options-for-django/) +本文探讨了 Django 应用程序的 ASGI 部署选项,提供了有关使用 ASGI 服务器部署 Django 的见解。 + +[Python 3.12 泛型简述](https://www.youtube.com/watch?v=TkDg3EHwC1g) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +Python 3.12 中的泛型可以通过允许类与不同的数据类型一起使用来转换代码,从而增强灵活性以及及早发现错误。该视频深入介绍了通用类和子类,并向您展示它们可以如何简化您的开发过程。 + +[使用 Google Cloud 自动化 Python](https://www.scipress.io/post/rSp9Rov4ppvHgpHQaRPy/Automating-Python-with-Google-Cloud) +一个教程系列,关于如何使用 Cloud Functions 和/或 Cloud Run 在 Google Cloud 中自动化 Python 脚本。 + +[GPT 可以优化我的税务吗?](https://finedataproducts.com/posts/2024-03-10-tax-scenarios-with-ai/) +这篇文章描述了一个使用 GPT-4 和 10 个 Python 库的 Web 应用程序,它允许用户输入税务场景并接收优化的税务计算和建议。与传统税务软件相比,该应用程序旨在提供更加灵活和个性化的税务咨询体验。 + +[Python 项目 —— 本地虚拟环境管理 Redux](https://hynek.me/articles/python-virtualenv-redux/) + +[2024 年我如何管理 Python](https://outlore.dev/blog/python-dev-2024/) + + +# 好玩的项目,工具和库 + +[SWE-agent](https://github.com/princeton-nlp/SWE-agent) +SWE-agent 将 LM(例如 GPT-4)转变为软件工程代理,可以修复真实 GitHub 存储库中的错误和问题。 + +[DBRX](https://github.com/databricks/dbrx) +DBRX( Databricks 开发的大型语言模型) 代码示例和资源。 + +[thepipe](https://github.com/emcf/thepipe) +通过一行代码将任何文件、文件夹、网站或存储库导出到 GPT-4-Vision。 + +[Sparrow](https://github.com/katanaml/sparrow) +使用 ML 和 LLM 进行数据处理。 + +[Nava](https://github.com/openscilab/nava) +用 Python 播放声音。 + +[IPEX-LLM](https://github.com/intel-analytics/ipex-llm) +一个 PyTorch 库,用于在 Intel CPU 和 GPU(例如,具有 iGPU 的本地 PC、Arc、Flex 和 Max 等独立 GPU)上运行 LLM,延迟非常低。 + +[RAGFlow](https://github.com/infiniflow/ragflow) +RAGFlow 是一个基于深度文档理解的开源 RAG(检索增强生成)引擎。 + + +# 最新发布 + +[Django 问题修复版本已发布:5.0.4](https://www.djangoproject.com/weblog/2024/apr/03/bugfix-release/) + + +# 近期活动和网络研讨会 + +[San Francisco Python 2024 年 4 月聚会](https://www.meetup.com/sfpython/events/298868858/) +将会有以下演讲: +* Prompt 工程:适用于 0.1 版代码 - 获得更快结果的途径 +* 更快运行 Pytest 的策略 + + +[PyData NYC 2024 年 4 月聚会](https://www.meetup.com/pydatanyc/events/300039833/) +将会有以下演讲: +* 时间序列预测简介 +* 使用 STUMPY 进行时间序列 EDA + + +[Pyladies Munich 2024 年 4 月聚会](https://www.meetup.com/pyladiesmunich/events/299309240/) +将会有以下演讲: +* 可观察性:原理与 Python 中的应用 +* 使用 Python 进行无缝云基础设施管理 +* 责任因素:同伴支持可以如何改变你的学习之旅 + + +[Freiburg Python 2024 年 4 月聚会](https://www.meetup.com/python-user-group-freiburg/events/299919455/) +将会有以下演讲: +* 事件系统 - JobRad 软件的演变 +* Docker 化 Python 应用程序及其安全性 + + +[PyData Munich 2024 年 4 月聚会](https://www.meetup.com/pydata-munchen/events/300083533/) +将会有以下演讲: +* 使用 dstack Sky 访问多个提供商的 GPU +* 更多标签或案例?评估自然语言推理中的标签变化 +* p(doom) —— 一个开放的、完全去中心化的全球人工智能研究实验室 diff --git a/Python Weekly/Python_Weekly_Issue_646.md b/Python Weekly/Python_Weekly_Issue_646.md new file mode 100644 index 0000000..d5eef5b --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_646.md @@ -0,0 +1,115 @@ +原文:[Python Weekly - Issue 646](http://eepurl.com/iNSLLo) + +--- + +欢迎来到《Python周刊》第 646 期。让我们直奔主题。 + + +# 文章,教程和讲座 + +[SQLAlchemy:Python 中最好的 SQL 数据库库](https://www.youtube.com/watch?v=aAy-B6KPld8) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +你听说过 SQLAlchemy 并觉得它听起来像中世纪的魔药吗?嗯,事实并非如此! SQLAlchemy 将 SQL 的稳健性与 Python 的灵活性相结合,使数据库管理不仅更容易,而且也很有趣!在本视频中,我将仔细看看这个很棒的工具。 + +[优秀表格的设计理念](https://posit-dev.github.io/great-tables/blog/design-philosophy) +本文讨论了精心设计的表格对于有效呈现数据的重要性,并从历史表格设计原则中汲取灵感。它强调了 Great Tables 库专注于提供各种自定义选项,以帮助用户为出版物、报告和其他数据驱动内容创建具有视觉吸引力和结构化的表格。 + +[14 个 LLM 参加了 314 场街头霸王比赛。这里是赢家。](https://community.aws/content/2dbNlQiqKvUtTBV15mHBqivckmo/14-llms-fought-314-street-fighter-matches-here-s-who-won)探索问答任务之外的大型语言模型的新基准。了解 LLM 如何使用 Amazon Bedrock 在街头霸王 III 中竞争。 + +[没有 API 的客户端库会更好](https://csvbase.com/blog/7) +本文讨论了作者为 csvbase 构建客户端库的方法,重点是利用现有的文件系统抽象库(如 fsspec)来提供无缝的用户体验,而无需自定义 API。它强调了这种方法的好处,例如可以与已经支持 fsspec 接口的各种工具和库集成。 + + +[使用 Django、Channels 和 HTMX 构建流式 ChatGPT 克隆](https://www.youtube.com/watch?v=8JSiiPW4S0A) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +此视频将引导您逐步使用 Django、websockets 和 HTMX 构建 ChatGPT 克隆。每个功能都被分解为一个提交,然后进行解释和演示。最后,一个功能齐全的流式聊天机器人应用程序就准备好了! + +[如何利用单行 Python 代码挺过编码面试](https://ivaniscoding.github.io/posts/codeinterview/) +本文讨论了使用简洁的单行 Python 代码解决编码面试问题的技术。 + +[Python 和 OpenAI 中的余弦相似度和文本嵌入](https://earthly.dev/blog/cosine_similarity_text_embeddings/) +本文讨论了如何使用余弦相似度来比较文本嵌入(文本嵌入是捕获语义的文本向量表示),以确定不同文本输入之间的相似度。它提供了示例代码,计算使用 OpenAI API 生成的文本嵌入之间的余弦相似度。 + +[六分钟内的 七个 Django GeneratedFiel 示例](https://www.youtube.com/watch?v=b7VkVHBX47w) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +我们将在 6 分钟内完成 7 个简短的示例。看完它们后,您将了解如何使用 Django 的 GeneratedField - 快速且整齐地使用数据库自动进行计算。 + +[使用 Python、Datalore 和 AI Assistant,回测交易策略](https://blog.jetbrains.com/datalore/2024/04/05/backtesting-a-trading-strategy-in-python-with-datalore-and-ai-assistant/) +本文将向您介绍在 Datalore 笔记本中使用 Python 回测每日道琼斯均值回归策略的过程。为了让编码经验有限的人也能使用它,作者利用了 Datalore 的 AI Assistant 功能。 + +[使用 Python 预测日食](https://erikbern.com/2024/04/07/predicting-solar-eclipses-with-python) +本文介绍了作者如何利用 Astropy 库和其他 Python 包,编写一个 Python 脚本来计算太阳和月亮的位置并预测日全食的位置,实现所有功能仅用了大约 100 行代码。 + + +# 好玩的项目,工具和库 + +[AutoCodeRover](https://github.com/nus-apr/auto-code-rover) +一个了解项目结构的自主软件工程师,旨在改进自主程序。 + +[FreeAskInternet](https://github.com/nashsu/FreeAskInternet) +FreeAskInternet 是一个完全免费、私有且本地运行的搜索聚合器,并使用 LLM 生成答案,无需 GPU。用户可以提出问题,然后系统会进行多引擎搜索,并将搜索结果合并到ChatGPT3.5 LLM中,再根据搜索结果生成答案。 + +[Loki](https://github.com/Libr-AI/OpenFactVerification) +用于事实验证的开源工具。 + +[schedule_free](https://github.com/facebookresearch/schedule_free) +PyTorch 中的无计划优化。 + +[Mantis](https://github.com/PhonePe/mantis) +Mantis 是一个安全框架,可自动执行发现、侦察和漏洞扫描的工作流程。 + +[open-parse](https://github.com/Filimoa/open-parse) +改进了 LLM 的文件解析。 + + +# 最新发布 + +[Visual Studio Code 中的 Python - 2024年四月版本](https://devblogs.microsoft.com/python/python-in-visual-studio-code-april-2024-release/) +此版本包括以下内容: +* 改进了 Flask 和 Django 的调试配置流程 +* 使用 Pylance,对 Jupyter 的运行依赖单元进行模块和导入分析 +* 孵化环境发现 +* Pipenv、pyenv 和 Poetry 项目的自动环境选择 +* 报告问题命令的改进 + + +[Python 3.11.9 现已发布](https://pythoninsider.blogspot.com/2024/04/python-3119-is-now-available.html) + +[Python 3.12.3 和 3.13.0a6 已发布](https://pythoninsider.blogspot.com/2024/04/python-3123-and-3130a6-released.html) + + +# 近期活动和网络研讨会 + +[Django London 2024 年 4 月聚会](https://www.meetup.com/djangolondon/events/299793290/) +将会有一场演讲:面向数据的 Django Deux。 + +[PyLadies London 2024 年 4 月聚会](https://www.meetup.com/pyladieslondon/events/299931279/) +将会有以下演讲: +* 使用 Elasticsearch 和 Python 进行语义搜索 +* Elastic 招聘 - 给求职者的提示和技巧 +* 高效的 Python 项目设置:展示 Cookiecutter 在 Kedro 中的潜力 + + +[Portland Python 2024 年 4 月聚会](https://www.meetup.com/pdxpython/events/300085006/) +将会有一场演讲:Python 中的生成器和迭代器。 + +[PyData Southampton 2024 年 4 月聚会](https://www.meetup.com/pydata-southampton/events/299810812/) +将会有以下演讲: +* 沙漠岛 Docker:Python 版本 +* 流数据帧:Python 中处理流数据的新方法 + + +[PyData Milano 2024 年 4 月聚会](https://www.meetup.com/pydata-milano/events/299954337/) +将会有以下演讲: +* 能源市场的波动期权定价:一个动态规划方法 +* 可解释人工智能:机遇与挑战 + + +[PyData Stockholm 2024 年 4 月聚会](https://www.meetup.com/pydatastockholm/events/300163813/) +将会有以下演讲: +* 用于基础模型预训练的大规模数据管理 +* Sana AI - 如何使用生成式人工智能构建消费级企业产品 + + +[PyData Manchester 2024 年 4 月聚会](https://www.meetup.com/pydata-manchester/events/299810769/) +将会有以下演讲: +* 关于制表的传奇故事 +* 开放数据和方法在气候价值分析中的重要性 + diff --git a/Python Weekly/Python_Weekly_Issue_647.md b/Python Weekly/Python_Weekly_Issue_647.md new file mode 100644 index 0000000..953d8a2 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_647.md @@ -0,0 +1,104 @@ +原文:[Python Weekly - Issue 647](http://eepurl.com/iOMKec) + +--- + +欢迎来到《Python周刊》第 647 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[从头开始学习 RAG](https://www.youtube.com/watch?v=sVcwVQRHIc8) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +直接从一位 LangChain 软件工程师那里学习如何从头开始实现 RAG(Retrieval Augmented Generation,检索增强生成)。本 Python 课程教您如何使用 RAG 将您自定义的数据与大型语言模型 (LLM) 的强大功能相结合。 + +[py2wasm 发布:一个从 Python 到 Wasm 的编译器](https://wasmer.io/posts/py2wasm-a-python-to-wasm-compiler) +py2wasm 将您的 Python 程序转换为 WebAssembly,运行速度提高了 3 倍。 + +[7 个令人兴奋的 Kubernetes Hack](https://overcast.blog/7-mind-blowing-kubernetes-hacks-36037e59bb54) +Kubernetes 拥有的一些功能,即使是经验丰富的开发人员也可能没有完全意识到。这些 Hack 深入研究了更深奥但非常有效的技巧,能让掌握它们的人的能力得到显着增强。这些不是您的日常技巧,而是让 Kubernetes 做出惊人事情的深刻见解。 + +[Python Big O:Python 中不同数据结构的时间复杂度](https://www.pythonmorsels.com/time-complexities/) +本文主要是为那些已经了解时间复杂度的概念以及操作的时间复杂度如何影响代码的人提供的一份 Python 时间复杂度备忘单。 + +[Django 的基本原则](https://www.mostlypython.com/django-from-first-principles-2/) +许多人没有意识到使用单个文件就可以启动 Django 项目。本系列将逐步介绍从单个文件开始构建一个简单但不平凡的项目的过程。仅当需要将代码移出主文件时,该项目才会使用第二个文件。在本系列结束时,我们的项目都结构将类似于 startproject 和 startapp 生成的项目结构。 + +[使用 Ollama 和 LlamaEdge,在本地运行 Llama 3](https://www.youtube.com/watch?v=wPuoMaD_SnY) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +Meta 推出了 Llama3,现在您可以使用 Ollama 在本地运行它。在本视频中,我将讲解如何使用 Ollama 操作各种语言模型,着重介绍 Llama2 和 Llama3。我还将指导您完成该项目的 WebUI,演示如何使用 Ollama 提供模型并使用 Python 与它们进行交互。 + +[Django:使用 Git 精确定位上游更改](https://adamj.eu/tech/2024/04/24/django-pinpoint-upstream-git/) +在这篇文章中,我们将介绍 Django 的分支结构、确定和搜索这些提交、一个有效的示例以及使用 git bisect 进行高级行为搜索。 + +[使用 Django 和 OpenAI 构建一个语音笔记应用程序](https://circumeo.io/blog/entry/building-a-voice-notes-app-with-django-and-openai/) +我们将构建一个使用 OpenAI 执行语音转文本的语音笔记应用程序。作为奖励,我们将使用 AlpineJS 来管理前端状态。 + +[8 分钟内使用 HTMX 和 Django 构建一个四子棋游戏](https://www.photondesigner.com/articles/connect4-htmx) +最后,您将利用 HTMX 构建一个多人游戏,使用简洁的服务器端逻辑并将所有结果存储在数据库中。 HTMX 是一种无需编写 JavaScript 即可使用 JavaScript 的好方法。 + +[使用 Langfuse 装饰器 (Python) 跟踪复杂的 LLM 应用程序](https://langfuse.com/blog/2024-04-python-decorator) +在构建 RAG 或代理时,大量 LLM 调用和非 LLM 输入会输入到最终输出中。 Langfuse装饰器可以让您进行整体追踪和评估。 + +[通过构建您自己的 ChatGPT,学习如何将 Websockets 与 Django 结合使用](https://www.saaspegasus.com/guides/django-websockets-chatgpt-channels-htmx/) +您需要了解的有关 Websockets 的所有信息,以便在您的应用程序中使用它们,包括 Django、通道和 HTMX。 + +[我不小心搞了一个 meme 搜索引擎](https://harper.blog/2024/04/12/i-accidentally-built-a-meme-search-engine) +又名:如何了解 Clip/siglip 和矢量编码图像。 + +[Llama 3:五分钟内搞定 LLM 构建](https://www.denoise.digital/llama-3-get-started-with-llms/) +使用 Llama 3、Ollama 和 Python,在 5 分钟内开始构建变革性的 AI 驱动功能。 + + +# 好玩的项目,工具和库 + +[CoreNet](https://github.com/apple/corenet) +Apple 用于训练深度神经网络的库。 + +[Cria](https://github.com/leftmove/cria) +Cria 是一个通过 Python 以编程方式运行大型语言模型的库。 Cria 的构建让您使用尽可能少的配置 - 即使是使用更高级的功能。 + +[bridge](https://github.com/Never-Over/bridge) +Django 的自动化基础设施。 + +[Penzai](https://github.com/google-deepmind/penzai) +用于构建、编辑和可视化神经网络的 JAX 研究工具包。 + +[BeyondLLM](https://github.com/aiplanethub/beyondllm) +构建、评估和观察 LLM 应用程序。 + +[Hashquery](https://github.com/hashboard-hq/hashquery) +用于定义和查询数据仓库中的 BI 模型的 Python 框架。 + +[torchtune](https://github.com/pytorch/torchtune) +用于 LLM 微调的 Native-PyTorch 库。 + +[InstructLab](https://github.com/instructlab/instructlab) +命令行界面。使用它与模型聊天或训练模型(训练消耗分类数据) + +[Portr](https://github.com/amalshaji/portr) +专为团队设计的开源 ngrok 替代方案 + +[anthropic-cookbook](https://github.com/anthropics/anthropic-cookbook) +notebooks/使用案例的集合,展示了使用 Claude 的一些有趣且有效的方法。 + + +# 最新发布 + +[llama3](https://github.com/meta-llama/llama3) +parameters.此版本包括用于预训练和指令调整的 Llama 3 语言模型的模型权重和起始代码 - 包括 8B 到 70B 参数的大小。 + +[PyTorch 2.3](https://pytorch.org/blog/pytorch2-3/) +PyTorch 2.3 支持用户在 torch.compile 中定义 Triton 内核,允许用户在不经历性能回归或图形中断的清空下,从 eager 迁移自己的 Triton 内核。Tensor 并行改进了使用本机 PyTorch 函数训练大型语言模型的体验,该功能已在包含 100B 个参数模型的训练运行中得到验证。此外,半结构化稀疏性将半结构化稀疏性实现为Tensor子类,观察到的加速比密集矩阵乘法高达 1.6。 + +# 近期活动和网络研讨会 + +[PyData Amsterdam 2024 年 4 月聚会](https://www.meetup.com/pydata-nl/events/300230051/) +将会有以下演讲: + * 生成式人工智能将如何使史基浦机场的客户服务提升到新高度 + * 释放武士:Albert Heijn 是如何让员工轻松检索内容的 + +[Hybrid: Michigan Python 2024 年 4 月聚会](https://www.meetup.com/michigan-python/events/299947904/) +将会有一场演讲:利用 DuckDB 加速 Python 数据分析。 + +[PyData Seattle 2024 年 4 月聚会](https://www.meetup.com/pydata_seattle/events/299433457/) +将会有以下演讲: + * DBRX 简介:Databricks 推出的一个新的 SOTA 开放 LLM + * Fidelius DBRXus:建立您自己私人霍格沃茨 + diff --git a/Python Weekly/Python_Weekly_Issue_648.md b/Python Weekly/Python_Weekly_Issue_648.md new file mode 100644 index 0000000..a1ef206 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_648.md @@ -0,0 +1,115 @@ +原文:[Python Weekly - Issue 648](http://eepurl.com/iPdo2g) + +--- + +欢迎来到《Python周刊》第 648 期。让我们直奔主题。 + + +# 新闻 + +[针对开发者的虚假工作面试,带新的 Python 后门](https://www.bleepingcomputer.com/news/security/fake-job-interviews-target-developers-with-new-python-backdoor/) +一项名为“Dev Popper”的新活动正在针对软件开发人员进行虚假工作面试,试图诱骗他们安装 Python 远程访问木马 (RAT)。开发人员被要求执行据称与采访相关的任务,例如从 GitHub 下载并运行代码,以使整个过程看起来合法。 + + +# 文章,教程和讲座 + +[Mojo Lang - 未来的高性能 Python?](https://www.youtube.com/watch?v=JRcXUuQYR90) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在本集中,我们将探讨 Mojo 的诞生原因,以及它为 Python 程序员和非 Python 程序员提供的服务。它是如何为性能而生的,以及哪些性能特征很重要?它对函数式编程和类型系统有何看法?它能否将 Python 的高级编程与 LLVM/MLIR 的低级编程结合起来? + +[Django:一个管理扩展,用于防止请求之间的状态泄漏](https://adamj.eu/tech/2024/04/29/django-admin-prevent-leaking-requests/) +这是我几年前添加到项目中的一个小保护。自从我在 Django 中间件中看到类似的潜在错误后,我再次考虑了这一点。 + +[使用 lm-buddy、Prometheus 和 llamafile 进行本地 LLM-as-judge 评估](https://blog.mozilla.ai/local-llm-as-judge-evaluation-with-lm-buddy-prometheus-and-llamafile) +这篇文章探讨了如何将不同的软件组件组合在一起,以允许 LLM-as-judge 评估而不需要昂贵的 GPU。所有组件都是根据其用户控制、开源性质和互操作性来构建和选择的。 + +[如何使用矢量搜索构建水晶图像搜索应用程序](https://www.datastax.com/blog/building-a-generative-ai-crystal-image-search-app-with-vector-search) +演示如何使用 Astra DB 构建应用程序来存储和查询水晶和宝石数据。该 Web 应用程序使用 RAGStack 构建,利用 CLIP 模型提供多模式搜索,从而检索各种晶体的数据。 + +[linux 上的单个python文件即可实现的“穷人式”自动重新加载服务器Poor mans autoreload server in single file python on linux](https://hereket.com/posts/linux_live_reload_python_server/) +本文描述了一个简单的 Python 服务器,它可以在内容更改时自动重新加载浏览器页面,而不需要任何额外的设置或配置。服务器充当常规文件服务器,但也可以通过指定路径提供 WebSocket 消息以触发页面重新加载。 + +[矢量嵌入的初学者指南](https://www.timescale.com/blog/a-beginners-guide-to-vector-embeddings/) +在本文中,我们将深入研究矢量嵌入,包括矢量嵌入的类型、神经网络如何创建它们、矢量嵌入的工作方式以及如何为数据创建嵌入。 + +[如何防止 pandas 和 scikit-learn 中的数据泄漏](https://www.dataschool.io/machine-learning-data-leakage/) +什么是数据泄漏,为什么会出现这样的问题,以及在 Python 中处理有监督机器学习问题时如何防止数据泄漏? + +[修补请求以获得乐趣和(并发)利润](https://blog.borrego.dev/entries/patching-requests-for-fun-and-concurrent-profit.html) +因为人生苦短,无法向 SSL_CTX_load_verify_locations() 发送垃圾邮件调用。 + +[Sleepsort:睡眠时排序](https://animeshchouhan.com/posts/sleepsort) +这篇文章介绍了“sleepsort”算法,这是一种奇怪的排序方法,它利用线程睡眠时间,按升序对整数进行排序。它对算法的功能和局限性进行了有趣且富有洞察力的探索。 + +[流式传输您的声音克隆](https://www.photondesigner.com/articles/voice-api) +我们将使用 Django,将您的声音变成无限可扩展的乐器。 + +[Python 中的异步协程对象方法](https://superfastpython.com/asyncio-coroutine-methods/) +我们可以在自定义 Python 对象上定义协程方法。这允许自定义 Python 对象上的方法使用 async/await 语法,例如,等待其他协程和任务,并允许在我们的 asyncio 程序中等待自定义协程方法本身。在本教程中,您将了解将对象方法定义为协程的方法。 + +[TypeIs 做了那些我认为 TypeGuard 在 Python 中会做的事儿](https://rednafi.com/python/typeguard_vs_typeis/) +本文讨论了 Python 中 TypeGuard 和 TypeIs 类型注释之间的差异。它解释了与 TypeGuard 相比,TypeIs 具有更直观的行为,特别是在处理联合类型时,并建议在大多数情况下使用 TypeIs 而不是 TypeGuard。 + + +# 好玩的项目,工具和库 + +[WebLlama](https://github.com/McGill-NLP/webllama) +Llama-3 代理,可以通过遵循说明并与您交谈来浏览网络。 + +[LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory) +统一对 100 多个 LLM 进行高效微调。 + +[tkforge](https://github.com/Axorax/tkforge) +在 Figma 中拖放即可轻松创建 Python GUI。 + +[TagStudio](https://github.com/TagStudioDev/TagStudio) +一个文件和照片管理应用程序和系统。 + +[torchtitan](https://github.com/pytorch/torchtitan) +用于大型模型训练的原生 PyTorch 库。 + +[LMDeploy](https://github.com/InternLM/lmdeploy) +LMDeploy 是一个用于压缩、部署和服务 LLM 的工具包。 + +[cohere-toolkit](https://github.com/cohere-ai/cohere-toolkit) +Toolkit 是一个预构建组件的集合,使用户能够快速构建和部署 RAG 应用程序。 + +[Cognita](https://github.com/truefoundry/cognita) +RAG (Retrieval Augmented Generation,检索增强生成) 框架,用于通过 TrueFoundry 构建可用于生产的模块化开源应用。 + +[databonsai](https://github.com/databonsai/databonsai) +使用 LLM 清理以及管理您的数据。 + +[tach](https://github.com/Never-Over/tach) +一个用于实施模块化、解耦包架构的 Python 工具。 + + +# 近期活动和网络研讨会 + +[Virtual: PyMNtos Python Presentation Night #125](https://www.meetup.com/pymntos-twin-cities-python-user-group/events/300536500/) +将会有以下演讲: +* 在 Excel 和 Power BI 中使用 Python +* 将 Python API 部署到云 + +[PyData NYC 2024 年 5 月聚会](https://www.meetup.com/pydatanyc/events/300430791/) +将会有以下演讲: +* Hopsworks 上具有特征、训练、推理管道的模块化 AI 系统 - LLMOps 教程 +* Modal 简介 + + +[PyData London 2024 年 5 月聚会](https://www.meetup.com/pydata-london-meetup/events/300415482/) +将会有以下演讲: +* 面向 Python 数据开发人员的 Microsoft Fabric +* 沙漠岛 Docker:Python 版 +* 为什么你应该害怕 Pickle +* 使用 Python 进行的 ASCII 艺术 + +[PyData Manchester 2024 年 5 月聚会](https://www.meetup.com/pydata-manchester/events/300228721/) +将会有以下演讲: +* 利用数据科学,从智能可穿戴设备中获取个人健康的见解 +* Python 找到它的魔力了吗?机器学习和人工智能的新语言 + +[PyData Rome 2024 年 5 月聚会](https://www.meetup.com/pydata-rome/events/300514196/) +将会有以下演讲: +* 计算机视觉 IRL:从想法到本地部署 +* 将地理空间数据与 Jupyter Notebook 和操作系统软件进行集成 + diff --git a/Python Weekly/Python_Weekly_Issue_649.md b/Python Weekly/Python_Weekly_Issue_649.md new file mode 100644 index 0000000..5eda2bd --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_649.md @@ -0,0 +1,114 @@ +原文:[Python Weekly - Issue 649](http://eepurl.com/iPGqBA) + +--- + +欢迎来到《Python周刊》第 649 期。让我们直奔主题。 + + +# 文章,教程和讲座 + +[ByteWax:当 Rust 当研究遇上 Python 的实用性](https://www.youtube.com/watch?v=ZRWun2MjTEg) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +Bytewax 是一种奇怪的流处理工具,它将 Python 表面与 Rust 核心混合在一起,产生与 Kafka Streams 或 Apache Flink 类似的东西,但实现方式截然不同。本周我们将了解它的作用、工作原理以及 Python 和 Rust 的结合在实践中如何工作。 + +[Python Asyncio 的工作原理:从头开始重新创建它](https://jacobpadilla.com/articles/recreating-asyncio) +通过使用 Python 生成器从头开始重新创建 asyncio 并使用 async/await 关键字的 __await__ 方法来了解 asyncio 的工作原理。 + + +[使用不安全的 Python 将速度提高一百倍](https://yosefk.com/blog/a-100x-speedup-with-unsafe-python.html) +我们将使用“不安全的 Python”将一些 numpy 代码的执行速度提高 100 倍。这与不安全的 Rust 不太一样,但有点相似,我不知道还能叫它什么……你会看到的。它不是您在大多数 Python 代码中使用的东西,但有时它很方便,而且我认为它从一个有趣的角度展示了“Python 的本质”。 + +[AsyncIO 和事件循环解释](https://www.youtube.com/watch?v=RIVcqT2OGPA) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +多年来,我制作了好几个关于 AsyncIO 的视频。然而,今天,我将采用一种新方法,即深入解释事件循环。我将更深入异步编程,特别关注事件循环在幕后的工作原理 + +[LLM 的工作原理(数学含量为零)](https://blog.miguelgrinberg.com/post/how-llms-work-explained-without-math) +我认为很多人对 GenAI 革命的一个基本问题是,这些模型的明显智能从何而来呢。在本文中,我将尝试用简单的术语而不是使用高级数学来解释通用文本模型的工作原理,从而帮助您将它们视为计算机算法,而不是魔法。 + +[会让你惊叹不已的简单交互式 Python Streamlit 地图](https://johnloewen.substack.com/p/simple-interactive-python-streamlit) +通过来自 NASA GIS 的数据集来讲述森林火灾统计数据 + +[掌握 Python 和 Zoom API|构建转录录音的服务器到服务器应用](https://www.youtube.com/watch?v=sQVliRl5uKw) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +在本分步指南中了解如何通过 Python 使用 Zoom 的 API!在本教程中,您将学习如何创建强大的服务器到服务器 OAuth 应用程序,该应用程序会自动转录您的 Zoom 录音,然后将其直接打印到您的终端,并将其另存为文本文件。本教程非常适合开发人员,它将引导您从设置到执行,因此在视频结束时,您将拥有一个功能齐全的应用程序。 + +[全同态加密的高级技术概述](https://www.jeremykun.com/2024/05/04/fhe-overview/) +本文提供了关于全同态加密 (FHE) 的高级技术概述,这是一种功能强大的加密技术,允许对加密数据执行计算而无需先解密。它讨论了一些正在积极开发的关键 FHE 库和工具。 + +[“请注意!”:注意力机制的视觉指南](https://codecompass00.substack.com/p/visual-guide-attention-mechanism-transformers) +培养注意力背后的直觉:为什么它接管了机器学习+LLM,以及它实际上做了什么。 + + +# 好玩的项目,工具和库 + +[gpt-home](https://github.com/judahpaul16/gpt-home) +家里的 ChatGPT!基本上是一个更好的 Google Nest Hub 或 Amazon Alexa 家庭助理。使用 OpenAI API 在 Raspberry Pi 上构建。 + +[Logfire](https://github.com/pydantic/logfire) +适用于 Python 及其他领域的简单可观察性! + +[PgQueuer](https://github.com/janbjorge/PgQueuer) +PgQueuer 是一个利用 PostgreSQL 实现高效作业排队的 Python 库。 + +[relax-py](https://github.com/crpier/relax-py) +用于 htmx 和 tailwindcss 的 Python Web 开发框架,具有热模块替换、URL 定位器、依赖项注入,由静态类型支持,构建在 Starlette 之上。 + +[VILA](https://github.com/Efficient-Large-Model/VILA) +一种多图像视觉语言模型,具有训练、推理和评估配方,可从云端部署到边缘(Jetson Orin 和笔记本电脑)。 + +[prometheus-eval](https://github.com/prometheus-eval/prometheus-eval) +使用 Prometheus 评估您的 LLM 的回应。 + +[LlamaParse](https://github.com/run-llama/llama_parse) +LlamaParse 是由 LlamaIndex 创建的 API,用于使用 LlamaIndex 框架高效地解析和表示文件,以实现高效检索和上下文增强。 + +[fastapi-cli](https://github.com/tiangolo/fastapi-cli) +使用 FastAPI CLI,从命令行运行和管理 FastAPI 应用程序。 + +[Bytewax](https://github.com/bytewax/bytewax) +Bytewax 是一个简化事件和流处理的 Python 框架。 + +[django-harlequin](https://github.com/adamchainz/django-harlequin) +使用 Django 数据库配置启动 Harlequin,终端的 SQL IDE。 + +[LeRobot](https://github.com/huggingface/lerobot) +适用于现实世界机器人的最先进的机器学习。 + +[Panza](https://github.com/IST-DASLab/PanzaMail) +个人电子邮件助理,经过训练并在设备上运行。 + +[DrEureka](https://eureka-research.github.io/dr-eureka/) +语言模型引导的模拟到真实的迁移。 + +[SATO](https://sato-team.github.io/Stable-Text-to-Motion-Framework/) +稳定的文本转动画框架。 + + +# 最新发布 + +[pip 24.1 beta](https://pip.pypa.io/en/latest/news/#b1-2024-05-06) + +[Django 问题修复版本已发布:5.0.6 和 4.2.13](https://www.djangoproject.com/weblog/2024/may/07/bugfix-releases/) + + +# 近期活动和网络研讨会 + +[Django London 2024 年 5 月聚会](https://www.meetup.com/djangolondon/events/300467704/) +将会有以下演讲: +* 用于大规模协作的分层 Django 项目结构 +* 蛇中有蟹! + +[PyLadies Berlin 2024 年 5 月聚会](https://www.meetup.com/pyladies-berlin/events/299598103/) +将会有以下演讲: +* 嵌套娃娃效应:Python 中的范围 +* `GridSearchCV` 中基于收入的评分:scikit-learn 中关于新元数据路由的一个案例 + +[PuPPy 2024 年 5 月聚会](https://www.meetup.com/psppython/events/300461407/) +将会有一场演讲:编写 Python 的最佳语言是 Rust。 + +[PyBerlin 2024 年 5 月聚会](https://www.meetup.com/pyberlin/events/291577883/) +将会有以下演讲: +* 仅使用 Python,在 Web 上部署数据项目 +* magic-di 简介:通过依赖注入器提升 Python + +[PyData Sudwest 2024 年 5 月聚会](https://www.meetup.com/pydata-suedwest/events/299870597/) +将会有以下演讲: +* Kickstart 大规模编码:项目模板自动化是如何释放开发人员的生产力的 +* Dask DataFrame 现在速度很快啦 diff --git a/Python Weekly/Python_Weekly_Issue_650.md b/Python Weekly/Python_Weekly_Issue_650.md new file mode 100644 index 0000000..2985260 --- /dev/null +++ b/Python Weekly/Python_Weekly_Issue_650.md @@ -0,0 +1,100 @@ +原文:[Python Weekly - Issue 650](http://eepurl.com/iP72qw) + +--- + +欢迎来到《Python周刊》第 650 期。让我们直奔主题。 + +# 文章,教程和讲座 + +[工作单元(Unit of Work)设计模式详解](https://www.youtube.com/watch?v=HX6vkP-QD7U) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +该视频解释了工作单元设计模式,对于经常与数据库交互的人来说,这是一个至关重要的概念。这种模式通过累积所有事务并集中执行它们来发挥关键作用。但为什么这是必要的呢?在此视频中找出答案吧。 + +[同像 Python](https://aljamal.substack.com/p/homoiconic-python) +本文探讨了编程语言中的同像概念,其中代码和数据是可以互换的,如 Lisp 所示。它提供了“Lisp in Lisp”代码子集的一个 Python 实现,展示了如何通过将代码视为可以操作和执行的数据结构来使 Python 变得同像。 + +[从头开始创建 DSPy 代理](https://learnbybuilding.ai/tutorials/dspy-agents-from-scratch) +本文将使用 DSPy,首次从头开始​​创建代理。出于教育目的,以及探索如何使用 DSPy 从头开始构建代理。 + +[滥用实际上是 Python 表达式的 Conda YAML 注释](https://astrid.tech/2024/02/24/0/conda-recipe-selector-abuse/) +我最喜欢的构建系统 jinja-preprocessed-eval-preprocessed YAML + +[用 Mojo 解析 PNG 图像](https://fnands.com/blog/2024/mojo-png-parsing/) +这篇文章详细介绍了作者使用 Mojo 编程语言实现 PNG 解析器的经验。它涵盖了所面临的挑战,例如处理无符号 8 位整数,以及将字节转换为字符串,同时探索为此任务编写 Mojo 代码的惯用方法。 + +[Tezos 区块链开发人员课程 – Python Web3 开发](https://www.youtube.com/watch?v=pHQfw1W7V8s) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +了解如何在 Tezos 上开发分布式应用程序,从设置钱包到有效理解和管理智能合约。该课程涵盖了 Tezos 开发人员必需的各种工具和技术,并重点介绍了支持平台发展的社区驱动创新。 + +[高影响力 Python Streamlit:漂亮的交互式地图和图表](https://johnloewen.substack.com/p/high-impact-python-streamlit-beautiful) +一种逐步模块化方法,采用 UNFAO 全球粮食不安全数据。 + +[如何将 Postgres 用作 Django 的简单任务队列](https://www.youtube.com/watch?v=kNGOcI_qqYo) ![](https://mcusercontent.com/e2e180baf855ac797ef407fc7/images/af76283a-6e65-436c-967a-900427cf6399.png) +将 Postgres 当作 Django 的任务队列是可以快速添加的。与传统方法(例如 Celery 和 Redis)相比,还有其他很大的优势。 + +[简介:使用 Python 和 Loguru 进行日志记录](https://www.blog.pythonlibrary.org/2024/05/15/an-intro-to-logging-with-python-and-loguru/) +Python 的日志记录模块并不是创建日志的唯一方法。您还可以使用几个第三方包。最受欢迎的包之一是 Loguru。 Loguru 打算删除使用 Python 日志记录 API 获得的所有样板文件。您会发现,Loguru 极大地简化了在 Python 中创建日志的过程。 + +[重塑 Python notebook 的经验教训](https://marimo.io/blog/lessons-learned) +本文讨论了开发 marimo(一个新的 Python 笔记本环境)时的关键原则和经验教训。它强调忠于项目的可重复性、可维护性和多用途设计的核心支柱,即使面临可能损害这些原则的功能需求。 + +[实时脑电波可视化:将 Muse EEG 与 Python 集成](https://ai9.notion.site/Real-Time-Brainwave-Visualization-Integrating-Muse-EEG-with-Python-54391bc09bf04b95a117d0fcf41ba351) + +[Django:根据子查询获取完整等模型实例](https://blog.bmispelon.rocks/articles/2024/2024-05-09-django-getting-a-full-model-instance-from-a-subquery.html) + + +# 好玩的项目,工具和库 + +[storm](https://github.com/stanford-oval/storm) +一个由 LLM 驱动的知识管理系统,用于研究主题并生成带有引文的完整报告。 + +[Frame](https://github.com/frame-lang/frame_transpiler) +Frame 是一种 Markdown 语言,用于在 Python 中创建状态机(自动机)以及生成 UML 文档。 + +[Pipecat](https://github.com/pipecat-ai/pipecat) +用于语音和多模式会话 AI 的开源框架。 + +[UXsim](https://github.com/toruseo/UXsim) +道路网络中的车辆交通流模拟器,纯Python编写。 + +[itrm](https://gitlab.com/davidwoodburn/itrm) +该库提供了多个函数,可以将数据很好地打印到终端。 + +[drf-api-action](https://github.com/Ori-Roza/drf-api-action) +利用 action_api 夹具提升了 Django Rest Framework 的测试,将 REST 端点测试简化为无缝、类似函数的体验。 + +[TimesFM](https://github.com/google-research/timesfm) +TimesFM(时间序列基础模型)是 Google Research 开发的用于时间序列预测的预训练时间序列基础模型。 + +[MindNLP](https://github.com/mindspore-lab/mindnlp) +基于MindSpore的易于使用的高性能NLP和LLM框架,兼容Huggingface的模型和数据集。 + +[llmware](https://github.com/llmware-ai/llmware) +提供企业级基于LLM的开发框架、工具和微调模型。 + + +# 近期活动和网络研讨会 + +[Hybrid: PyMunich 2024 年 5 月聚会](https://www.meetup.com/pymunich/events/299650733/) +将会有以下演讲: +* 利用 Streamlit 成为数据故事讲述者 +* 自动发布技术文档(Git-to-Confluence) +* 融合视角:为当今项目中的不同团队编写干净的 Python 代码 + +[PyLadies Paris 2024 年 5 月聚会](https://www.meetup.com/pyladiesparis/events/300641629/) +将有一场演讲:从 ML 模型调试到机器人检测 - Sliceline 的故事。 + +[Python Barcelona 2024 年 5 月聚会](https://www.meetup.com/python-barcelona/events/300940146/) +将会有以下演讲: +* 在 AI 中使用 OpenCV:Python 中的实用图像处理 +* cluster-experiments,一个用于设计 AB 测试的模拟库 + + +[BAyPIGgies 2024 年 5 月聚会](https://www.meetup.com/baypiggies/events/300647354/) +将会有以下演讲: +* 使用 Pandas 和 Pyspark 对仪器数据进行时间序列处理。 +* 使用 Reflex 开发全栈 Python Web 应用程序 + + +[PyData Berlin 2024 年 5 月聚会](https://www.meetup.com/pydata-berlin/events/300633031/) +将会有以下演讲: +* 超越连续体:深度学习中量化的重要性 +* 思想碰撞 \ No newline at end of file diff --git a/Python Weekly/README.md b/Python Weekly/README.md index 76149f2..5bf1385 100644 --- a/Python Weekly/README.md +++ b/Python Weekly/README.md @@ -2,134 +2,172 @@ 本目录是Python Weekly的中译版,从Issue 243开始。 -- [Issue 243](./Python_Weekly_Issue_243.md) -- [Issue 244](./Python_Weekly_Issue_244.md) -- [Issue 245](./Python_Weekly_Issue_245.md) -- [Issue 246](./Python_Weekly_Issue_246.md) -- [Issue 247](./Python_Weekly_Issue_247.md) -- [Issue 248](./Python_Weekly_Issue_248.md) -- [Issue 249](./Python_Weekly_Issue_249.md) -- [Issue 250](./Python_Weekly_Issue_250.md) -- [Issue 251](./Python_Weekly_Issue_251.md) -- [Issue 252](./Python_Weekly_Issue_252.md) -- [Issue 253](./Python_Weekly_Issue_253.md) -- [Issue 254](./Python_Weekly_Issue_254.md) -- [Issue 255](./Python_Weekly_Issue_255.md) -- [Issue 256](./Python_Weekly_Issue_256.md) -- [Issue 257](./Python_Weekly_Issue_257.md) -- [Issue 258](./Python_Weekly_Issue_258.md) -- [Issue 259](./Python_Weekly_Issue_259.md) -- [Issue 260](./Python_Weekly_Issue_260.md) -- [Issue 261](./Python_Weekly_Issue_261.md) -- [Issue 262](./Python_Weekly_Issue_262.md) -- [Issue 263](./Python_Weekly_Issue_263.md) -- [Issue 264](./Python_Weekly_Issue_264.md) -- [Issue 265](./Python_Weekly_Issue_265.md) -- [Issue 266](./Python_Weekly_Issue_266.md) -- [Issue 267](./Python_Weekly_Issue_267.md) -- [Issue 268](./Python_Weekly_Issue_268.md) -- [Issue 269](./Python_Weekly_Issue_269.md) -- [Issue 270](./Python_Weekly_Issue_270.md) -- [Issue 271](./Python_Weekly_Issue_271.md) -- [Issue 272](./Python_Weekly_Issue_272.md) -- [Issue 273](./Python_Weekly_Issue_273.md) -- [Issue 274](./Python_Weekly_Issue_274.md) -- [Issue 275](./Python_Weekly_Issue_275.md) -- [Issue 276](./Python_Weekly_Issue_276.md) -- [Issue 277](./Python_Weekly_Issue_277.md) -- [Issue 278](./Python_Weekly_Issue_278.md) -- [Issue 279](./Python_Weekly_Issue_279.md) -- [Issue 280](./Python_Weekly_Issue_280.md) -- [Issue 281](./Python_Weekly_Issue_281.md) -- [Issue 282](./Python_Weekly_Issue_282.md) -- [Issue 283](./Python_Weekly_Issue_283.md) -- [Issue 284](./Python_Weekly_Issue_284.md) -- [Issue 285](./Python_Weekly_Issue_285.md) -- [Issue 286](./Python_Weekly_Issue_286.md) -- [Issue 287](./Python_Weekly_Issue_287.md) -- [Issue 288](./Python_Weekly_Issue_288.md) -- [Issue 289](./Python_Weekly_Issue_289.md) -- [Issue 290](./Python_Weekly_Issue_290.md) -- [Issue 291](./Python_Weekly_Issue_291.md) -- [Issue 292](./Python_Weekly_Issue_292.md) -- [Issue 293](./Python_Weekly_Issue_293.md) -- [Issue 294](./Python_Weekly_Issue_294.md) -- [Issue 295](./Python_Weekly_Issue_295.md) -- [Issue 296](./Python_Weekly_Issue_296.md) -- [Issue 297](./Python_Weekly_Issue_297.md) -- [Issue 298](./Python_Weekly_Issue_298.md) -- [Issue 299](./Python_Weekly_Issue_299.md) -- [Issue 300](./Python_Weekly_Issue_300.md) -- [Issue 301](./Python_Weekly_Issue_301.md) -- [Issue 302](./Python_Weekly_Issue_302.md) -- [Issue 303](./Python_Weekly_Issue_303.md) -- [Issue 304](./Python_Weekly_Issue_304.md) -- [Issue 305](./Python_Weekly_Issue_305.md) -- [Issue 306](./Python_Weekly_Issue_306.md) -- [Issue 307](./Python_Weekly_Issue_307.md) -- [Issue 308](./Python_Weekly_Issue_308.md) -- [Issue 309](./Python_Weekly_Issue_309.md) -- [Issue 310](./Python_Weekly_Issue_310.md) -- [Issue 311](./Python_Weekly_Issue_311.md) -- [Issue 312](./Python_Weekly_Issue_312.md) -- [Issue 313](./Python_Weekly_Issue_313.md) -- [Issue 314](./Python_Weekly_Issue_314.md) -- [Issue 315](./Python_Weekly_Issue_315.md) -- [Issue 316](./Python_Weekly_Issue_316.md) -- [Issue 317](./Python_Weekly_Issue_317.md) -- [Issue 318](./Python_Weekly_Issue_318.md) -- [Issue 319](./Python_Weekly_Issue_319.md) -- [Issue 320](./Python_Weekly_Issue_320.md) -- [Issue 321](./Python_Weekly_Issue_321.md) -- [Issue 322](./Python_Weekly_Issue_322.md) -- [Issue 323](./Python_Weekly_Issue_323.md) -- [Issue 324](./Python_Weekly_Issue_324.md) -- [Issue 325](./Python_Weekly_Issue_325.md) -- [Issue 326](./Python_Weekly_Issue_326.md) -- [Issue 327](./Python_Weekly_Issue_327.md) -- [Issue 328](./Python_Weekly_Issue_328.md) -- [Issue 329](./Python_Weekly_Issue_329.md) -- [Issue 330](./Python_Weekly_Issue_330.md) -- [Issue 331](./Python_Weekly_Issue_331.md) -- [Issue 332](./Python_Weekly_Issue_332.md) -- [Issue 333](./Python_Weekly_Issue_333.md) -- [Issue 334](./Python_Weekly_Issue_334.md) -- [Issue 335](./Python_Weekly_Issue_335.md) -- [Issue 336](./Python_Weekly_Issue_336.md) -- [Issue 337](./Python_Weekly_Issue_337.md) -- [Issue 338](./Python_Weekly_Issue_338.md) -- [Issue 339](./Python_Weekly_Issue_339.md) -- [Issue 340](./Python_Weekly_Issue_340.md) -- [Issue 341](./Python_Weekly_Issue_341.md) -- [Issue 342](./Python_Weekly_Issue_342.md) -- [Issue 343](./Python_Weekly_Issue_343.md) -- [Issue 344](./Python_Weekly_Issue_344.md) -- [Issue 345](./Python_Weekly_Issue_345.md) -- [Issue 346](./Python_Weekly_Issue_346.md) -- [Issue 347](./Python_Weekly_Issue_347.md) -- [Issue 348](./Python_Weekly_Issue_348.md) -- [Issue 349](./Python_Weekly_Issue_349.md) -- [Issue 350](./Python_Weekly_Issue_350.md) -- [Issue 351](./Python_Weekly_Issue_351.md) -- [Issue 352](./Python_Weekly_Issue_352.md) -- [Issue 353](./Python_Weekly_Issue_353.md) -- [Issue 354](./Python_Weekly_Issue_354.md) -- [Issue 355](./Python_Weekly_Issue_355.md) -- [Issue 356](./Python_Weekly_Issue_356.md) -- [Issue 357](./Python_Weekly_Issue_357.md) -- [Issue 358](./Python_Weekly_Issue_358.md) -- [Issue 359](./Python_Weekly_Issue_359.md) -- [Issue 360](./Python_Weekly_Issue_360.md) -- [Issue 361](./Python_Weekly_Issue_361.md) -- [Issue 362](./Python_Weekly_Issue_362.md) -- [Issue 363](./Python_Weekly_Issue_363.md) -- [Issue 364](./Python_Weekly_Issue_364.md) -- [Issue 365](./Python_Weekly_Issue_365.md) -- [Issue 374](./Python_Weekly_Issue_374.md) -- [Issue 375](./Python_Weekly_Issue_375.md) -- [Issue 376](./Python_Weekly_Issue_376.md) -- [Issue 377](./Python_Weekly_Issue_377.md) -- [Issue 378](./Python_Weekly_Issue_378.md) -- [Issue 379](./Python_Weekly_Issue_379.md) +- [Issue 650](./Python_Weekly_Issue_650.md) +- [Issue 649](./Python_Weekly_Issue_649.md) +- [Issue 648](./Python_Weekly_Issue_648.md) +- [Issue 647](./Python_Weekly_Issue_647.md) +- [Issue 646](./Python_Weekly_Issue_646.md) +- [Issue 645](./Python_Weekly_Issue_645.md) +- [Issue 644](./Python_Weekly_Issue_644.md) +- [Issue 643](./Python_Weekly_Issue_643.md) +- [Issue 642](./Python_Weekly_Issue_642.md) +- [Issue 641](./Python_Weekly_Issue_641.md) +- [Issue 640](./Python_Weekly_Issue_640.md) +- [Issue 639](./Python_Weekly_Issue_639.md) +- [Issue 638](./Python_Weekly_Issue_638.md) +- [Issue 637](./Python_Weekly_Issue_637.md) +- [Issue 636](./Python_Weekly_Issue_636.md) +- [Issue 635](./Python_Weekly_Issue_635.md) +- [Issue 634](./Python_Weekly_Issue_634.md) +- [Issue 633](./Python_Weekly_Issue_633.md) +- [Issue 632](./Python_Weekly_Issue_632.md) +- [Issue 631](./Python_Weekly_Issue_631.md) +- [Issue 630](./Python_Weekly_Issue_630.md) +- [Issue 629](./Python_Weekly_Issue_629.md) +- [Issue 628](./Python_Weekly_Issue_628.md) +- [Issue 627](./Python_Weekly_Issue_627.md) +- [Issue 626](./Python_Weekly_Issue_626.md) +- [Issue 625](./Python_Weekly_Issue_625.md) +- [Issue 624](./Python_Weekly_Issue_624.md) +- [Issue 623](./Python_Weekly_Issue_623.md) +- [Issue 622](./Python_Weekly_Issue_622.md) +- [Issue 621](./Python_Weekly_Issue_621.md) +- [Issue 620](./Python_Weekly_Issue_620.md) +- [Issue 619](./Python_Weekly_Issue_619.md) +- [Issue 618](./Python_Weekly_Issue_618.md) +- [Issue 617](./Python_Weekly_Issue_617.md) +- [Issue 386](./Python_Weekly_Issue_386.md) +- [Issue 385](./Python_Weekly_Issue_385.md) +- [Issue 384](./Python_Weekly_Issue_384.md) +- [Issue 383](./Python_Weekly_Issue_383.md) +- [Issue 381](./Python_Weekly_Issue_381.md) - [Issue 380](./Python_Weekly_Issue_380.md) -- [Issue 381](./Python_Weekly_Issue_381.md) \ No newline at end of file +- [Issue 379](./Python_Weekly_Issue_379.md) +- [Issue 378](./Python_Weekly_Issue_378.md) +- [Issue 377](./Python_Weekly_Issue_377.md) +- [Issue 376](./Python_Weekly_Issue_376.md) +- [Issue 375](./Python_Weekly_Issue_375.md) +- [Issue 374](./Python_Weekly_Issue_374.md) +- [Issue 365](./Python_Weekly_Issue_365.md) +- [Issue 364](./Python_Weekly_Issue_364.md) +- [Issue 363](./Python_Weekly_Issue_363.md) +- [Issue 362](./Python_Weekly_Issue_362.md) +- [Issue 361](./Python_Weekly_Issue_361.md) +- [Issue 360](./Python_Weekly_Issue_360.md) +- [Issue 359](./Python_Weekly_Issue_359.md) +- [Issue 358](./Python_Weekly_Issue_358.md) +- [Issue 357](./Python_Weekly_Issue_357.md) +- [Issue 356](./Python_Weekly_Issue_356.md) +- [Issue 355](./Python_Weekly_Issue_355.md) +- [Issue 354](./Python_Weekly_Issue_354.md) +- [Issue 353](./Python_Weekly_Issue_353.md) +- [Issue 352](./Python_Weekly_Issue_352.md) +- [Issue 351](./Python_Weekly_Issue_351.md) +- [Issue 350](./Python_Weekly_Issue_350.md) +- [Issue 349](./Python_Weekly_Issue_349.md) +- [Issue 348](./Python_Weekly_Issue_348.md) +- [Issue 347](./Python_Weekly_Issue_347.md) +- [Issue 346](./Python_Weekly_Issue_346.md) +- [Issue 345](./Python_Weekly_Issue_345.md) +- [Issue 344](./Python_Weekly_Issue_344.md) +- [Issue 343](./Python_Weekly_Issue_343.md) +- [Issue 342](./Python_Weekly_Issue_342.md) +- [Issue 341](./Python_Weekly_Issue_341.md) +- [Issue 340](./Python_Weekly_Issue_340.md) +- [Issue 339](./Python_Weekly_Issue_339.md) +- [Issue 338](./Python_Weekly_Issue_338.md) +- [Issue 337](./Python_Weekly_Issue_337.md) +- [Issue 336](./Python_Weekly_Issue_336.md) +- [Issue 335](./Python_Weekly_Issue_335.md) +- [Issue 334](./Python_Weekly_Issue_334.md) +- [Issue 333](./Python_Weekly_Issue_333.md) +- [Issue 332](./Python_Weekly_Issue_332.md) +- [Issue 331](./Python_Weekly_Issue_331.md) +- [Issue 330](./Python_Weekly_Issue_330.md) +- [Issue 329](./Python_Weekly_Issue_329.md) +- [Issue 328](./Python_Weekly_Issue_328.md) +- [Issue 327](./Python_Weekly_Issue_327.md) +- [Issue 326](./Python_Weekly_Issue_326.md) +- [Issue 325](./Python_Weekly_Issue_325.md) +- [Issue 324](./Python_Weekly_Issue_324.md) +- [Issue 323](./Python_Weekly_Issue_323.md) +- [Issue 322](./Python_Weekly_Issue_322.md) +- [Issue 321](./Python_Weekly_Issue_321.md) +- [Issue 320](./Python_Weekly_Issue_320.md) +- [Issue 319](./Python_Weekly_Issue_319.md) +- [Issue 318](./Python_Weekly_Issue_318.md) +- [Issue 317](./Python_Weekly_Issue_317.md) +- [Issue 316](./Python_Weekly_Issue_316.md) +- [Issue 315](./Python_Weekly_Issue_315.md) +- [Issue 314](./Python_Weekly_Issue_314.md) +- [Issue 313](./Python_Weekly_Issue_313.md) +- [Issue 312](./Python_Weekly_Issue_312.md) +- [Issue 311](./Python_Weekly_Issue_311.md) +- [Issue 310](./Python_Weekly_Issue_310.md) +- [Issue 309](./Python_Weekly_Issue_309.md) +- [Issue 308](./Python_Weekly_Issue_308.md) +- [Issue 307](./Python_Weekly_Issue_307.md) +- [Issue 306](./Python_Weekly_Issue_306.md) +- [Issue 305](./Python_Weekly_Issue_305.md) +- [Issue 304](./Python_Weekly_Issue_304.md) +- [Issue 303](./Python_Weekly_Issue_303.md) +- [Issue 302](./Python_Weekly_Issue_302.md) +- [Issue 301](./Python_Weekly_Issue_301.md) +- [Issue 300](./Python_Weekly_Issue_300.md) +- [Issue 299](./Python_Weekly_Issue_299.md) +- [Issue 298](./Python_Weekly_Issue_298.md) +- [Issue 297](./Python_Weekly_Issue_297.md) +- [Issue 296](./Python_Weekly_Issue_296.md) +- [Issue 295](./Python_Weekly_Issue_295.md) +- [Issue 294](./Python_Weekly_Issue_294.md) +- [Issue 293](./Python_Weekly_Issue_293.md) +- [Issue 292](./Python_Weekly_Issue_292.md) +- [Issue 291](./Python_Weekly_Issue_291.md) +- [Issue 290](./Python_Weekly_Issue_290.md) +- [Issue 289](./Python_Weekly_Issue_289.md) +- [Issue 288](./Python_Weekly_Issue_288.md) +- [Issue 287](./Python_Weekly_Issue_287.md) +- [Issue 286](./Python_Weekly_Issue_286.md) +- [Issue 285](./Python_Weekly_Issue_285.md) +- [Issue 284](./Python_Weekly_Issue_284.md) +- [Issue 283](./Python_Weekly_Issue_283.md) +- [Issue 282](./Python_Weekly_Issue_282.md) +- [Issue 281](./Python_Weekly_Issue_281.md) +- [Issue 280](./Python_Weekly_Issue_280.md) +- [Issue 279](./Python_Weekly_Issue_279.md) +- [Issue 278](./Python_Weekly_Issue_278.md) +- [Issue 277](./Python_Weekly_Issue_277.md) +- [Issue 276](./Python_Weekly_Issue_276.md) +- [Issue 275](./Python_Weekly_Issue_275.md) +- [Issue 274](./Python_Weekly_Issue_274.md) +- [Issue 273](./Python_Weekly_Issue_273.md) +- [Issue 272](./Python_Weekly_Issue_272.md) +- [Issue 271](./Python_Weekly_Issue_271.md) +- [Issue 270](./Python_Weekly_Issue_270.md) +- [Issue 269](./Python_Weekly_Issue_269.md) +- [Issue 268](./Python_Weekly_Issue_268.md) +- [Issue 267](./Python_Weekly_Issue_267.md) +- [Issue 266](./Python_Weekly_Issue_266.md) +- [Issue 265](./Python_Weekly_Issue_265.md) +- [Issue 264](./Python_Weekly_Issue_264.md) +- [Issue 263](./Python_Weekly_Issue_263.md) +- [Issue 262](./Python_Weekly_Issue_262.md) +- [Issue 261](./Python_Weekly_Issue_261.md) +- [Issue 260](./Python_Weekly_Issue_260.md) +- [Issue 259](./Python_Weekly_Issue_259.md) +- [Issue 258](./Python_Weekly_Issue_258.md) +- [Issue 257](./Python_Weekly_Issue_257.md) +- [Issue 256](./Python_Weekly_Issue_256.md) +- [Issue 255](./Python_Weekly_Issue_255.md) +- [Issue 254](./Python_Weekly_Issue_254.md) +- [Issue 253](./Python_Weekly_Issue_253.md) +- [Issue 252](./Python_Weekly_Issue_252.md) +- [Issue 251](./Python_Weekly_Issue_251.md) +- [Issue 250](./Python_Weekly_Issue_250.md) +- [Issue 249](./Python_Weekly_Issue_249.md) +- [Issue 248](./Python_Weekly_Issue_248.md) +- [Issue 247](./Python_Weekly_Issue_247.md) +- [Issue 246](./Python_Weekly_Issue_246.md) +- [Issue 245](./Python_Weekly_Issue_245.md) +- [Issue 244](./Python_Weekly_Issue_244.md) +- [Issue 243](./Python_Weekly_Issue_243.md) \ No newline at end of file diff --git a/README.md b/README.md index 8116465..5a1f289 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# pythondocument +# Python Document translate python documents to Chinese for convenient reference 简而言之,这里用来存放那些Python文档君们,并且尽力将其翻译成中文~~ @@ -15,8 +15,8 @@ gitbook地址:[Python Chinese documents](https://ictar.gitbooks.io/python-doc- - [Python Common](./Python%20Common 'python 常规文档') python 常规文档 ## Web框架 -- [Django](./Django) Django 相关文档 -- [Flask](./Flask) Flask相关文档 +- [Django](./Web/Django) Django 相关文档 +- [Flask](./Web/Flask) Flask相关文档 ## web爬取 - [Scrapy](./Scrapy) Scrapy相关文档 @@ -69,3 +69,9 @@ gitbook地址:[Python Chinese documents](https://ictar.gitbooks.io/python-doc- # 贡献者 - [lujun9972](https://github.com/lujun9972) + +# 捐赠 +如果你觉得这个项目对你有帮助,那就请我喝杯东西吧 Buy Me A Coffee + +--- +[![Star History Chart](https://api.star-history.com/svg?repos=ictar/python-doc&type=Date)](https://star-history.com/?utm_source=bestxtools.com#ictar/python-doc&Date) diff --git a/SUMMARY.md b/SUMMARY.md index 88d259e..3c94f98 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -118,137 +118,6 @@ ## 资源 - [Python Weekly](./Python Weekly/README.md) - - [Issue 243](./Python Weekly/Python_Weekly_Issue_243.md) - - [Issue 244](./Python Weekly/Python_Weekly_Issue_244.md) - - [Issue 245](./Python Weekly/Python_Weekly_Issue_245.md) - - [Issue 246](./Python Weekly/Python_Weekly_Issue_246.md) - - [Issue 247](./Python Weekly/Python_Weekly_Issue_247.md) - - [Issue 248](./Python Weekly/Python_Weekly_Issue_248.md) - - [Issue 249](./Python Weekly/Python_Weekly_Issue_249.md) - - [Issue 250](./Python Weekly/Python_Weekly_Issue_250.md) - - [Issue 251](./Python Weekly/Python_Weekly_Issue_251.md) - - [Issue 252](./Python Weekly/Python_Weekly_Issue_252.md) - - [Issue 253](./Python Weekly/Python_Weekly_Issue_253.md) - - [Issue 254](./Python Weekly/Python_Weekly_Issue_254.md) - - [Issue 255](./Python Weekly/Python_Weekly_Issue_255.md) - - [Issue 256](./Python Weekly/Python_Weekly_Issue_256.md) - - [Issue 257](./Python Weekly/Python_Weekly_Issue_257.md) - - [Issue 258](./Python Weekly/Python_Weekly_Issue_258.md) - - [Issue 259](./Python Weekly/Python_Weekly_Issue_259.md) - - [Issue 260](./Python Weekly/Python_Weekly_Issue_260.md) - - [Issue 261](./Python Weekly/Python_Weekly_Issue_261.md) - - [Issue 262](./Python Weekly/Python_Weekly_Issue_262.md) - - [Issue 263](./Python Weekly/Python_Weekly_Issue_263.md) - - [Issue 264](./Python Weekly/Python_Weekly_Issue_264.md) - - [Issue 265](./Python Weekly/Python_Weekly_Issue_265.md) - - [Issue 266](./Python Weekly/Python_Weekly_Issue_266.md) - - [Issue 267](./Python Weekly/Python_Weekly_Issue_267.md) - - [Issue 268](./Python Weekly/Python_Weekly_Issue_268.md) - - [Issue 269](./Python Weekly/Python_Weekly_Issue_269.md) - - [Issue 270](./Python Weekly/Python_Weekly_Issue_270.md) - - [Issue 271](./Python Weekly/Python_Weekly_Issue_271.md) - - [Issue 272](./Python Weekly/Python_Weekly_Issue_272.md) - - [Issue 273](./Python Weekly/Python_Weekly_Issue_273.md) - - [Issue 274](./Python Weekly/Python_Weekly_Issue_274.md) - - [Issue 275](./Python Weekly/Python_Weekly_Issue_275.md) - - [Issue 276](./Python Weekly/Python_Weekly_Issue_276.md) - - [Issue 277](./Python Weekly/Python_Weekly_Issue_277.md) - - [Issue 278](./Python Weekly/Python_Weekly_Issue_278.md) - - [Issue 279](./Python Weekly/Python_Weekly_Issue_279.md) - - [Issue 280](./Python Weekly/Python_Weekly_Issue_280.md) - - [Issue 281](./Python Weekly/Python_Weekly_Issue_281.md) - - [Issue 282](./Python Weekly/Python_Weekly_Issue_282.md) - - [Issue 283](./Python Weekly/Python_Weekly_Issue_283.md) - - [Issue 284](./Python Weekly/Python_Weekly_Issue_284.md) - - [Issue 285](./Python Weekly/Python_Weekly_Issue_285.md) - - [Issue 286](./Python Weekly/Python_Weekly_Issue_286.md) - - [Issue 287](./Python Weekly/Python_Weekly_Issue_287.md) - - [Issue 288](./Python Weekly/Python_Weekly_Issue_288.md) - - [Issue 289](./Python Weekly/Python_Weekly_Issue_289.md) - - [Issue 290](./Python Weekly/Python_Weekly_Issue_290.md) - - [Issue 291](./Python Weekly/Python_Weekly_Issue_291.md) - - [Issue 292](./Python Weekly/Python_Weekly_Issue_292.md) - - [Issue 293](./Python Weekly/Python_Weekly_Issue_293.md) - - [Issue 294](./Python Weekly/Python_Weekly_Issue_294.md) - - [Issue 295](./Python Weekly/Python_Weekly_Issue_295.md) - - [Issue 296](./Python Weekly/Python_Weekly_Issue_296.md) - - [Issue 297](./Python Weekly/Python_Weekly_Issue_297.md) - - [Issue 298](./Python Weekly/Python_Weekly_Issue_298.md) - - [Issue 299](./Python Weekly/Python_Weekly_Issue_299.md) - - [Issue 300](./Python Weekly/Python_Weekly_Issue_300.md) - - [Issue 301](./Python Weekly/Python_Weekly_Issue_301.md) - - [Issue 302](./Python Weekly/Python_Weekly_Issue_302.md) - - [Issue 303](./Python Weekly/Python_Weekly_Issue_303.md) - - [Issue 304](./Python Weekly/Python_Weekly_Issue_304.md) - - [Issue 305](./Python Weekly/Python_Weekly_Issue_305.md) - - [Issue 306](./Python Weekly/Python_Weekly_Issue_306.md) - - [Issue 307](./Python Weekly/Python_Weekly_Issue_307.md) - - [Issue 308](./Python Weekly/Python_Weekly_Issue_308.md) - - [Issue 309](./Python Weekly/Python_Weekly_Issue_309.md) - - [Issue 310](./Python Weekly/Python_Weekly_Issue_310.md) - - [Issue 311](./Python Weekly/Python_Weekly_Issue_311.md) - - [Issue 312](./Python Weekly/Python_Weekly_Issue_312.md) - - [Issue 313](./Python Weekly/Python_Weekly_Issue_313.md) - - [Issue 314](./Python Weekly/Python_Weekly_Issue_314.md) - - [Issue 315](./Python Weekly/Python_Weekly_Issue_315.md) - - [Issue 316](./Python Weekly/Python_Weekly_Issue_316.md) - - [Issue 317](./Python Weekly/Python_Weekly_Issue_317.md) - - [Issue 318](./Python Weekly/Python_Weekly_Issue_318.md) - - [Issue 319](./Python Weekly/Python_Weekly_Issue_319.md) - - [Issue 320](./Python Weekly/Python_Weekly_Issue_320.md) - - [Issue 321](./Python Weekly/Python_Weekly_Issue_321.md) - - [Issue 322](./Python Weekly/Python_Weekly_Issue_322.md) - - [Issue 323](./Python Weekly/Python_Weekly_Issue_323.md) - - [Issue 324](./Python Weekly/Python_Weekly_Issue_324.md) - - [Issue 325](./Python Weekly/Python_Weekly_Issue_325.md) - - [Issue 326](./Python Weekly/Python_Weekly_Issue_326.md) - - [Issue 327](./Python Weekly/Python_Weekly_Issue_327.md) - - [Issue 328](./Python Weekly/Python_Weekly_Issue_328.md) - - [Issue 329](./Python Weekly/Python_Weekly_Issue_329.md) - - [Issue 330](./Python Weekly/Python_Weekly_Issue_330.md) - - [Issue 331](./Python Weekly/Python_Weekly_Issue_331.md) - - [Issue 332](./Python Weekly/Python_Weekly_Issue_332.md) - - [Issue 333](./Python Weekly/Python_Weekly_Issue_333.md) - - [Issue 334](./Python Weekly/Python_Weekly_Issue_334.md) - - [Issue 335](./Python Weekly/Python_Weekly_Issue_335.md) - - [Issue 336](./Python Weekly/Python_Weekly_Issue_336.md) - - [Issue 337](./Python Weekly/Python_Weekly_Issue_337.md) - - [Issue 338](./Python Weekly/Python_Weekly_Issue_338.md) - - [Issue 339](./Python Weekly/Python_Weekly_Issue_339.md) - - [Issue 340](./Python Weekly/Python_Weekly_Issue_340.md) - - [Issue 341](./Python Weekly/Python_Weekly_Issue_341.md) - - [Issue 342](./Python Weekly/Python_Weekly_Issue_342.md) - - [Issue 343](./Python Weekly/Python_Weekly_Issue_343.md) - - [Issue 344](./Python Weekly/Python_Weekly_Issue_344.md) - - [Issue 345](./Python Weekly/Python_Weekly_Issue_345.md) - - [Issue 346](./Python Weekly/Python_Weekly_Issue_346.md) - - [Issue 347](./Python Weekly/Python_Weekly_Issue_347.md) - - [Issue 348](./Python Weekly/Python_Weekly_Issue_348.md) - - [Issue 349](./Python Weekly/Python_Weekly_Issue_349.md) - - [Issue 350](./Python Weekly/Python_Weekly_Issue_350.md) - - [Issue 351](./Python Weekly/Python_Weekly_Issue_351.md) - - [Issue 352](./Python Weekly/Python_Weekly_Issue_352.md) - - [Issue 353](./Python Weekly/Python_Weekly_Issue_353.md) - - [Issue 354](./Python Weekly/Python_Weekly_Issue_354.md) - - [Issue 355](./Python Weekly/Python_Weekly_Issue_355.md) - - [Issue 356](./Python Weekly/Python_Weekly_Issue_356.md) - - [Issue 357](./Python Weekly/Python_Weekly_Issue_357.md) - - [Issue 358](./Python Weekly/Python_Weekly_Issue_358.md) - - [Issue 359](./Python Weekly/Python_Weekly_Issue_359.md) - - [Issue 360](./Python Weekly/Python_Weekly_Issue_360.md) - - [Issue 361](./Python Weekly/Python_Weekly_Issue_361.md) - - [Issue 362](./Python Weekly/Python_Weekly_Issue_362.md) - - [Issue 363](./Python Weekly/Python_Weekly_Issue_363.md) - - [Issue 364](./Python Weekly/Python_Weekly_Issue_364.md) - - [Issue 365](./Python Weekly/Python_Weekly_Issue_365.md) - - [Issue 374](./Python Weekly/Python_Weekly_Issue_374.md) - - [Issue 375](./Python Weekly/Python_Weekly_Issue_375.md) - - [Issue 376](./Python Weekly/Python_Weekly_Issue_376.md) - - [Issue 377](./Python Weekly/Python_Weekly_Issue_377.md) - - [Issue 378](./Python Weekly/Python_Weekly_Issue_378.md) - - [Issue 379](./Python Weekly/Python_Weekly_Issue_379.md) - - [Issue 380](./Python Weekly/Python_Weekly_Issue_380.md) - - [Issue 381](./Python Weekly/Python_Weekly_Issue_381.md) ## 无法归类的 - [Others](./Others/README.md) diff --git a/Django/1.9/README.md b/Web/Django/1.9/README.md similarity index 100% rename from Django/1.9/README.md rename to Web/Django/1.9/README.md diff --git a/Django/1.9/howto/Managing static files (e.g. images, JavaScript, CSS).md b/Web/Django/1.9/howto/Managing static files (e.g. images, JavaScript, CSS).md similarity index 100% rename from Django/1.9/howto/Managing static files (e.g. images, JavaScript, CSS).md rename to Web/Django/1.9/howto/Managing static files (e.g. images, JavaScript, CSS).md diff --git "a/Django/1.9/howto/\344\275\277\347\224\250Django\350\276\223\345\207\272CSV.md" "b/Web/Django/1.9/howto/\344\275\277\347\224\250Django\350\276\223\345\207\272CSV.md" similarity index 100% rename from "Django/1.9/howto/\344\275\277\347\224\250Django\350\276\223\345\207\272CSV.md" rename to "Web/Django/1.9/howto/\344\275\277\347\224\250Django\350\276\223\345\207\272CSV.md" diff --git "a/Django/1.9/howto/\344\275\277\347\224\250Django\350\276\223\345\207\272PDF.md" "b/Web/Django/1.9/howto/\344\275\277\347\224\250Django\350\276\223\345\207\272PDF.md" similarity index 100% rename from "Django/1.9/howto/\344\275\277\347\224\250Django\350\276\223\345\207\272PDF.md" rename to "Web/Django/1.9/howto/\344\275\277\347\224\250Django\350\276\223\345\207\272PDF.md" diff --git "a/Django/1.9/howto/\345\246\202\344\275\225\344\275\277\347\224\250WSGI\350\277\233\350\241\214\351\203\250\347\275\262.md" "b/Web/Django/1.9/howto/\345\246\202\344\275\225\344\275\277\347\224\250WSGI\350\277\233\350\241\214\351\203\250\347\275\262.md" similarity index 100% rename from "Django/1.9/howto/\345\246\202\344\275\225\344\275\277\347\224\250WSGI\350\277\233\350\241\214\351\203\250\347\275\262.md" rename to "Web/Django/1.9/howto/\345\246\202\344\275\225\344\275\277\347\224\250WSGI\350\277\233\350\241\214\351\203\250\347\275\262.md" diff --git "a/Django/1.9/howto/\351\203\250\347\275\262Django.md" "b/Web/Django/1.9/howto/\351\203\250\347\275\262Django.md" similarity index 100% rename from "Django/1.9/howto/\351\203\250\347\275\262Django.md" rename to "Web/Django/1.9/howto/\351\203\250\347\275\262Django.md" diff --git "a/Django/1.9/misc/\350\256\276\350\256\241\347\220\206\345\277\265.md" "b/Web/Django/1.9/misc/\350\256\276\350\256\241\347\220\206\345\277\265.md" similarity index 100% rename from "Django/1.9/misc/\350\256\276\350\256\241\347\220\206\345\277\265.md" rename to "Web/Django/1.9/misc/\350\256\276\350\256\241\347\220\206\345\277\265.md" diff --git "a/Django/1.9/ref/\344\270\255\351\227\264\344\273\266.md" "b/Web/Django/1.9/ref/\344\270\255\351\227\264\344\273\266.md" similarity index 100% rename from "Django/1.9/ref/\344\270\255\351\227\264\344\273\266.md" rename to "Web/Django/1.9/ref/\344\270\255\351\227\264\344\273\266.md" diff --git "a/Django/1.9/topics/db/\346\225\260\346\215\256\345\272\223\350\256\277\351\227\256\344\274\230\345\214\226.md" "b/Web/Django/1.9/topics/db/\346\225\260\346\215\256\345\272\223\350\256\277\351\227\256\344\274\230\345\214\226.md" similarity index 100% rename from "Django/1.9/topics/db/\346\225\260\346\215\256\345\272\223\350\256\277\351\227\256\344\274\230\345\214\226.md" rename to "Web/Django/1.9/topics/db/\346\225\260\346\215\256\345\272\223\350\256\277\351\227\256\344\274\230\345\214\226.md" diff --git "a/Django/1.9/topics/db/\346\250\241\345\236\213.md" "b/Web/Django/1.9/topics/db/\346\250\241\345\236\213.md" similarity index 100% rename from "Django/1.9/topics/db/\346\250\241\345\236\213.md" rename to "Web/Django/1.9/topics/db/\346\250\241\345\236\213.md" diff --git a/Django/1.9/topics/forms/Form Assets (the Media class).md b/Web/Django/1.9/topics/forms/Form Assets (the Media class).md similarity index 100% rename from Django/1.9/topics/forms/Form Assets (the Media class).md rename to Web/Django/1.9/topics/forms/Form Assets (the Media class).md diff --git "a/Django/1.9/topics/forms/\344\275\277\347\224\250\350\241\250\345\215\225.md" "b/Web/Django/1.9/topics/forms/\344\275\277\347\224\250\350\241\250\345\215\225.md" similarity index 100% rename from "Django/1.9/topics/forms/\344\275\277\347\224\250\350\241\250\345\215\225.md" rename to "Web/Django/1.9/topics/forms/\344\275\277\347\224\250\350\241\250\345\215\225.md" diff --git a/Django/1.9/topics/http/File Uploads.md b/Web/Django/1.9/topics/http/File Uploads.md similarity index 100% rename from Django/1.9/topics/http/File Uploads.md rename to Web/Django/1.9/topics/http/File Uploads.md diff --git "a/Django/1.9/topics/http/\344\270\255\351\227\264\344\273\266.md" "b/Web/Django/1.9/topics/http/\344\270\255\351\227\264\344\273\266.md" similarity index 100% rename from "Django/1.9/topics/http/\344\270\255\351\227\264\344\273\266.md" rename to "Web/Django/1.9/topics/http/\344\270\255\351\227\264\344\273\266.md" diff --git "a/Django/1.9/topics/i18n/\345\233\275\351\231\205\345\214\226\345\222\214\346\234\254\345\234\260\345\214\226.md" "b/Web/Django/1.9/topics/i18n/\345\233\275\351\231\205\345\214\226\345\222\214\346\234\254\345\234\260\345\214\226.md" similarity index 100% rename from "Django/1.9/topics/i18n/\345\233\275\351\231\205\345\214\226\345\222\214\346\234\254\345\234\260\345\214\226.md" rename to "Web/Django/1.9/topics/i18n/\345\233\275\351\231\205\345\214\226\345\222\214\346\234\254\345\234\260\345\214\226.md" diff --git "a/Django/1.9/topics/i18n/\347\277\273\350\257\221\357\274\210\350\275\254\346\215\242\357\274\211.md" "b/Web/Django/1.9/topics/i18n/\347\277\273\350\257\221\357\274\210\350\275\254\346\215\242\357\274\211.md" similarity index 100% rename from "Django/1.9/topics/i18n/\347\277\273\350\257\221\357\274\210\350\275\254\346\215\242\357\274\211.md" rename to "Web/Django/1.9/topics/i18n/\347\277\273\350\257\221\357\274\210\350\275\254\346\215\242\357\274\211.md" diff --git "a/Django/1.9/topics/testing/\345\234\250Django\344\270\255\346\265\213\350\257\225.md" "b/Web/Django/1.9/topics/testing/\345\234\250Django\344\270\255\346\265\213\350\257\225.md" similarity index 100% rename from "Django/1.9/topics/testing/\345\234\250Django\344\270\255\346\265\213\350\257\225.md" rename to "Web/Django/1.9/topics/testing/\345\234\250Django\344\270\255\346\265\213\350\257\225.md" diff --git "a/Django/1.9/topics/testing/\347\274\226\345\206\231\345\222\214\350\277\220\350\241\214\346\265\213\350\257\225.md" "b/Web/Django/1.9/topics/testing/\347\274\226\345\206\231\345\222\214\350\277\220\350\241\214\346\265\213\350\257\225.md" similarity index 100% rename from "Django/1.9/topics/testing/\347\274\226\345\206\231\345\222\214\350\277\220\350\241\214\346\265\213\350\257\225.md" rename to "Web/Django/1.9/topics/testing/\347\274\226\345\206\231\345\222\214\350\277\220\350\241\214\346\265\213\350\257\225.md" diff --git "a/Django/1.9/topics/\346\200\247\350\203\275\345\222\214\344\274\230\345\214\226\346\246\202\350\277\260.md" "b/Web/Django/1.9/topics/\346\200\247\350\203\275\345\222\214\344\274\230\345\214\226\346\246\202\350\277\260.md" similarity index 100% rename from "Django/1.9/topics/\346\200\247\350\203\275\345\222\214\344\274\230\345\214\226\346\246\202\350\277\260.md" rename to "Web/Django/1.9/topics/\346\200\247\350\203\275\345\222\214\344\274\230\345\214\226\346\246\202\350\277\260.md" diff --git "a/Django/1.9/topics/\346\227\245\345\277\227.md" "b/Web/Django/1.9/topics/\346\227\245\345\277\227.md" similarity index 100% rename from "Django/1.9/topics/\346\227\245\345\277\227.md" rename to "Web/Django/1.9/topics/\346\227\245\345\277\227.md" diff --git "a/Django/1.9/topics/\346\250\241\346\235\277.md" "b/Web/Django/1.9/topics/\346\250\241\346\235\277.md" similarity index 100% rename from "Django/1.9/topics/\346\250\241\346\235\277.md" rename to "Web/Django/1.9/topics/\346\250\241\346\235\277.md" diff --git "a/Django/1.9/topics/\350\256\276\347\275\256.md" "b/Web/Django/1.9/topics/\350\256\276\347\275\256.md" similarity index 100% rename from "Django/1.9/topics/\350\256\276\347\275\256.md" rename to "Web/Django/1.9/topics/\350\256\276\347\275\256.md" diff --git "a/Django/Django Channels\345\222\214Celery\347\244\272\344\276\213.md" "b/Web/Django/Django Channels\345\222\214Celery\347\244\272\344\276\213.md" similarity index 100% rename from "Django/Django Channels\345\222\214Celery\347\244\272\344\276\213.md" rename to "Web/Django/Django Channels\345\222\214Celery\347\244\272\344\276\213.md" diff --git "a/Django/Django, ELB\345\201\245\345\272\267\346\243\200\346\237\245\345\222\214\346\214\201\347\273\255\344\272\244\344\273\230.md" "b/Web/Django/Django, ELB\345\201\245\345\272\267\346\243\200\346\237\245\345\222\214\346\214\201\347\273\255\344\272\244\344\273\230.md" similarity index 100% rename from "Django/Django, ELB\345\201\245\345\272\267\346\243\200\346\237\245\345\222\214\346\214\201\347\273\255\344\272\244\344\273\230.md" rename to "Web/Django/Django, ELB\345\201\245\345\272\267\346\243\200\346\237\245\345\222\214\346\214\201\347\273\255\344\272\244\344\273\230.md" diff --git "a/Django/Django\344\270\255\346\255\243\347\241\256\345\244\204\347\220\206\346\225\260\346\215\256\345\272\223\345\271\266\345\217\221\347\232\204\346\226\271\346\263\225.md" "b/Web/Django/Django\344\270\255\346\255\243\347\241\256\345\244\204\347\220\206\346\225\260\346\215\256\345\272\223\345\271\266\345\217\221\347\232\204\346\226\271\346\263\225.md" similarity index 100% rename from "Django/Django\344\270\255\346\255\243\347\241\256\345\244\204\347\220\206\346\225\260\346\215\256\345\272\223\345\271\266\345\217\221\347\232\204\346\226\271\346\263\225.md" rename to "Web/Django/Django\344\270\255\346\255\243\347\241\256\345\244\204\347\220\206\346\225\260\346\215\256\345\272\223\345\271\266\345\217\221\347\232\204\346\226\271\346\263\225.md" diff --git a/Django/README.md b/Web/Django/README.md similarity index 100% rename from Django/README.md rename to Web/Django/README.md diff --git "a/Django/\344\275\277\347\224\250Django\350\277\233\350\241\214\345\216\237\345\236\213\345\214\226.md" "b/Web/Django/\344\275\277\347\224\250Django\350\277\233\350\241\214\345\216\237\345\236\213\345\214\226.md" similarity index 100% rename from "Django/\344\275\277\347\224\250Django\350\277\233\350\241\214\345\216\237\345\236\213\345\214\226.md" rename to "Web/Django/\344\275\277\347\224\250Django\350\277\233\350\241\214\345\216\237\345\236\213\345\214\226.md" diff --git "a/Django/\344\275\277\347\224\250Kubernetes\344\275\277Django\345\272\224\347\224\250\345\217\230\345\276\227\345\217\257\346\211\251\345\261\225\345\271\266\345\205\267\346\234\211\345\274\271\346\200\247.md" "b/Web/Django/\344\275\277\347\224\250Kubernetes\344\275\277Django\345\272\224\347\224\250\345\217\230\345\276\227\345\217\257\346\211\251\345\261\225\345\271\266\345\205\267\346\234\211\345\274\271\346\200\247.md" similarity index 100% rename from "Django/\344\275\277\347\224\250Kubernetes\344\275\277Django\345\272\224\347\224\250\345\217\230\345\276\227\345\217\257\346\211\251\345\261\225\345\271\266\345\205\267\346\234\211\345\274\271\346\200\247.md" rename to "Web/Django/\344\275\277\347\224\250Kubernetes\344\275\277Django\345\272\224\347\224\250\345\217\230\345\276\227\345\217\257\346\211\251\345\261\225\345\271\266\345\205\267\346\234\211\345\274\271\346\200\247.md" diff --git "a/Django/\345\234\250Django\344\270\255\357\274\214\345\246\202\344\275\225\344\270\272\346\217\220\351\253\230\351\241\265\351\235\242\345\212\240\350\275\275\351\200\237\345\272\246\344\274\230\345\214\226\345\233\276\345\203\217.md" "b/Web/Django/\345\234\250Django\344\270\255\357\274\214\345\246\202\344\275\225\344\270\272\346\217\220\351\253\230\351\241\265\351\235\242\345\212\240\350\275\275\351\200\237\345\272\246\344\274\230\345\214\226\345\233\276\345\203\217.md" similarity index 100% rename from "Django/\345\234\250Django\344\270\255\357\274\214\345\246\202\344\275\225\344\270\272\346\217\220\351\253\230\351\241\265\351\235\242\345\212\240\350\275\275\351\200\237\345\272\246\344\274\230\345\214\226\345\233\276\345\203\217.md" rename to "Web/Django/\345\234\250Django\344\270\255\357\274\214\345\246\202\344\275\225\344\270\272\346\217\220\351\253\230\351\241\265\351\235\242\345\212\240\350\275\275\351\200\237\345\272\246\344\274\230\345\214\226\345\233\276\345\203\217.md" diff --git "a/Django/\345\246\202\344\275\225\346\211\251\345\261\225Django User\346\250\241\345\236\213.md" "b/Web/Django/\345\246\202\344\275\225\346\211\251\345\261\225Django User\346\250\241\345\236\213.md" similarity index 100% rename from "Django/\345\246\202\344\275\225\346\211\251\345\261\225Django User\346\250\241\345\236\213.md" rename to "Web/Django/\345\246\202\344\275\225\346\211\251\345\261\225Django User\346\250\241\345\236\213.md" diff --git "a/Django/\345\270\246django\346\225\231\347\250\213\347\232\204Facebook\350\201\212\345\244\251\346\234\272\345\231\250\344\272\272\357\274\214\345\217\210\345\220\215\347\254\221\350\257\235\346\234\272\345\231\250\344\272\272.md" "b/Web/Django/\345\270\246django\346\225\231\347\250\213\347\232\204Facebook\350\201\212\345\244\251\346\234\272\345\231\250\344\272\272\357\274\214\345\217\210\345\220\215\347\254\221\350\257\235\346\234\272\345\231\250\344\272\272.md" similarity index 100% rename from "Django/\345\270\246django\346\225\231\347\250\213\347\232\204Facebook\350\201\212\345\244\251\346\234\272\345\231\250\344\272\272\357\274\214\345\217\210\345\220\215\347\254\221\350\257\235\346\234\272\345\231\250\344\272\272.md" rename to "Web/Django/\345\270\246django\346\225\231\347\250\213\347\232\204Facebook\350\201\212\345\244\251\346\234\272\345\231\250\344\272\272\357\274\214\345\217\210\345\220\215\347\254\221\350\257\235\346\234\272\345\231\250\344\272\272.md" diff --git a/Flask/README.md b/Web/Flask/README.md similarity index 100% rename from Flask/README.md rename to Web/Flask/README.md diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/README.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/README.md" new file mode 100644 index 0000000..beff5db --- /dev/null +++ "b/\350\257\273\344\271\246\347\254\224\350\256\260/README.md" @@ -0,0 +1,2 @@ +* [官方 python 教程(python 3)](https://docs.python.org/zh-cn/3/tutorial/index.html) | [思维导图](http://naotu.baidu.com/file/a50273db8bba3a2c7f257f039d06e7c1?token=f389efed04f2e4b8) +* \ No newline at end of file diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/1. Python \346\225\260\346\215\256\346\250\241\345\236\213.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/1. Python \346\225\260\346\215\256\346\250\241\345\236\213.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/10.\345\272\217\345\210\227\347\232\204\344\277\256\346\224\271\343\200\201\346\225\243\345\210\227\345\222\214\345\210\207\347\211\207.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/10.\345\272\217\345\210\227\347\232\204\344\277\256\346\224\271\343\200\201\346\225\243\345\210\227\345\222\214\345\210\207\347\211\207.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/11.\346\216\245\345\217\243\357\274\232\344\273\216\345\215\217\350\256\256\345\210\260\346\212\275\350\261\241\345\237\272\347\261\273.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/11.\346\216\245\345\217\243\357\274\232\344\273\216\345\215\217\350\256\256\345\210\260\346\212\275\350\261\241\345\237\272\347\261\273.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/12.\347\273\247\346\211\277\347\232\204\344\274\230\347\274\272\347\202\271.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/12.\347\273\247\346\211\277\347\232\204\344\274\230\347\274\272\347\202\271.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/13.\346\255\243\347\241\256\351\207\215\350\275\275\350\277\220\347\256\227\347\254\246.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/13.\346\255\243\347\241\256\351\207\215\350\275\275\350\277\220\347\256\227\347\254\246.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/14. \345\217\257\345\217\240\346\210\264\347\232\204\345\257\271\350\261\241\343\200\201\350\277\255\344\273\243\345\231\250\345\222\214\347\224\237\346\210\220\345\231\250.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/14. \345\217\257\345\217\240\346\210\264\347\232\204\345\257\271\350\261\241\343\200\201\350\277\255\344\273\243\345\231\250\345\222\214\347\224\237\346\210\220\345\231\250.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/15. \344\270\212\344\270\213\346\226\207\347\256\241\347\220\206\345\231\250\345\222\214 else \345\235\227.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/15. \344\270\212\344\270\213\346\226\207\347\256\241\347\220\206\345\231\250\345\222\214 else \345\235\227.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/16. \345\215\217\347\250\213.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/16. \345\215\217\347\250\213.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/17. \344\275\277\347\224\250\346\234\237\347\211\251\345\244\204\347\220\206\345\271\266\345\217\221.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/17. \344\275\277\347\224\250\346\234\237\347\211\251\345\244\204\347\220\206\345\271\266\345\217\221.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/18. \344\275\277\347\224\250 asyncio \345\214\205\345\244\204\347\220\206\345\271\266\345\217\221.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/18. \344\275\277\347\224\250 asyncio \345\214\205\345\244\204\347\220\206\345\271\266\345\217\221.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/19. \345\212\250\346\200\201\345\261\236\346\200\247\345\222\214\347\211\271\346\200\247.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/19. \345\212\250\346\200\201\345\261\236\346\200\247\345\222\214\347\211\271\346\200\247.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/2. \345\272\217\345\210\227\346\236\204\346\210\220\347\232\204\346\225\260\347\273\204.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/2. \345\272\217\345\210\227\346\236\204\346\210\220\347\232\204\346\225\260\347\273\204.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/20. \345\261\236\346\200\247\346\217\217\350\277\260\347\254\246.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/20. \345\261\236\346\200\247\346\217\217\350\277\260\347\254\246.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/21. \347\261\273\345\205\203\347\274\226\347\250\213.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/21. \347\261\273\345\205\203\347\274\226\347\250\213.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/3. \345\255\227\345\205\270\345\222\214\351\233\206\345\220\210.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/3. \345\255\227\345\205\270\345\222\214\351\233\206\345\220\210.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/4. \346\226\207\346\234\254\345\222\214\345\255\227\350\212\202\345\272\217\345\210\227.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/4. \346\226\207\346\234\254\345\222\214\345\255\227\350\212\202\345\272\217\345\210\227.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/5.\344\270\200\347\255\211\345\207\275\346\225\260.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/5.\344\270\200\347\255\211\345\207\275\346\225\260.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/6.\344\275\277\347\224\250\344\270\200\347\255\211\345\207\275\346\225\260\345\256\236\347\216\260\350\256\276\350\256\241\346\250\241\345\274\217.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/6.\344\275\277\347\224\250\344\270\200\347\255\211\345\207\275\346\225\260\345\256\236\347\216\260\350\256\276\350\256\241\346\250\241\345\274\217.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/7.\345\207\275\346\225\260\350\243\205\351\245\260\345\231\250\345\222\214\351\227\255\345\214\205.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/7.\345\207\275\346\225\260\350\243\205\351\245\260\345\231\250\345\222\214\351\227\255\345\214\205.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/8.\345\257\271\350\261\241\345\274\225\347\224\250\343\200\201\345\217\257\345\217\230\346\200\247\345\222\214\345\236\203\345\234\276\345\233\236\346\224\266.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/8.\345\257\271\350\261\241\345\274\225\347\224\250\343\200\201\345\217\257\345\217\230\346\200\247\345\222\214\345\236\203\345\234\276\345\233\236\346\224\266.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/9.\347\254\246\345\220\210 python \351\243\216\346\240\274\347\232\204\345\257\271\350\261\241.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/9.\347\254\246\345\220\210 python \351\243\216\346\240\274\347\232\204\345\257\271\350\261\241.md" new file mode 100644 index 0000000..e69de29 diff --git "a/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/README.md" "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/README.md" new file mode 100644 index 0000000..80a56e4 --- /dev/null +++ "b/\350\257\273\344\271\246\347\254\224\350\256\260/\346\265\201\347\225\205\347\232\204 python/README.md" @@ -0,0 +1,9 @@ +# 流畅的 python + +### 本书源代码 +地址:[fluentpython/example-code](https://github.com/fluentpython/example-code) + +使用方式: +``` +$ python3 -m doctest example_script.py +``` \ No newline at end of file