当前位置: 首页 > news >正文

python study notes[4]

文章目录

  • reference counting
  • CFFI
  • function
  • Arbitrary Argument Lists
  • references

reference counting

  1. reference counting is by no means part of the garbage collecting stratege ,the objects will be not released although they do not serve for accessing.
  2. the garbage collecting facilities of CPython has a few flaws which reference-counting is too strong restriction.for example, if you open a lot of files and forget to close them,then the CPython’s GC cycle inspect them repeatedly.so many opend files which is by no means used lead to not only the waste of memory but also reduction of GC’s efficiency. In this situation, weak references may is the best solution.
  3. the weakref survives except for few event such as reference cycles while the __del__() function runs.the del of object can be only called once in PyPy, but CPython perhaps call it more than once bacause that the object can resurrect and die again,by the way,the newer CPythons call destructors one time only.

CFFI

  1. CFFI is a recommended way which help python programmer to call C code with C libraries.CFFI is available for both CPython and PyPy,the PyPy’s JIT also support it.
  2. CFFI contribute to call C code from Python without a 3rd language.

function

  1. the arguments passed into function may be both poistion and keyword.
    for example:
def fun1(x=1,y,z):return x+y+z
fun1(11,22,z=6)
fun1(y=33,z=22)

/ and * can be used in parameters of function for indicating that positional-only, positional-or-keyword, and keyword-only.that is as follows.

def fun(a, b,         /, x, *,      y1,y2):-----------    ----------     ----------|             |                  ||        Positional or keyword   ||                                - Keyword only-- Positional only

for example:

def fun1(x,y,/,z1,z2,*,a,b):print(x+y+z1+z2+a+b)
fun1(11,22,z2=33,z1=99,a=4,b=9)
fun1(11,22,33,z2=99,a=4,b=9)

Arbitrary Argument Lists

  1. the * symbol indicates the following variable actually represent a list.
def fun1(*nums):nsum=0for n in nums:print(n)nsum+=nprint(nsum)
fun1(11,22,58,-458)
fun1(11,22,33,99,49)

references

  1. https://doc.pypy.org/
http://www.dtcms.com/a/335476.html

相关文章:

  • Vue深入组件:Props 详解3
  • 【adb端口5555】烽火hg680-gy_烽火hg680-gc安卓9线刷烧录包 解决用一段时间就提示升级的问题
  • 回溯剪枝的 “减法艺术”:化解超时危机的 “救命稻草”(一)
  • 如何在 Ubuntu 24.04、22.04 或 20.04 Linux 中更改计算机名称
  • 智能化管理:开启海洋牧场新时代
  • 字节 Golang 大模型应用开发框架 Eino简介
  • Vue深入组件:Props 详解2
  • es7.17.x es服务yellow状态的排查查看节点,分片状态数量
  • 42 C++ STL模板库11-容器4-forward_list
  • C++算法竞赛:位运算
  • 线程(基本概念和相关命令)
  • CT01-反转链表(Java)
  • 从零开始:SpringBoot与KingbaseES的完美融合实践
  • 基于飞算JavaAI的可视化数据分析集成系统项目实践:从需求到落地的全流程解析
  • Java 大视界 -- Java 大数据分布式计算在基因测序数据分析与精准医疗中的应用(400)
  • Excel 表格数据自动填充
  • 【线程安全(二) Java EE】
  • 基于飞算JavaAI实现布隆过滤器防止缓存穿透:原理、实践与全流程解析
  • 【电路笔记 通信】AXI4-Lite协议 FPGA实现 Valid-Ready Handshake 握手协议
  • 【计算机网络面试】键入网址到网页显示期间,发生了什么?
  • Tomcat Connector连接器原理
  • Bee1.17.25更新Bug,完善功能.不支持NOSQL,分库分表Sharding(2.X版有)
  • Rust Async 异步编程(一):入门
  • AI评测的科学之道:当Benchmark遇上统计学
  • uniapp中uni.showToast和 uni.showLoading同时使用时出现提示中断冲突问题。
  • Maven 开发实践
  • Java ConcurrentHashMap 深度解析
  • Mitt 事件发射器完全指南:200字节的轻量级解决方案
  • Git 命令指南:从 0 到熟练、从常用到“几乎全集”(含常见报错与解决)建议收藏!!!
  • Leetcode 深度优先搜索 (2)