
python pickle
torch.save 和 torch.load 默认使用的 pickle 模块进行序列化和反序列化。在调用 torch.load 时偶尔会遇到缺失类的问题。这篇文章仔细分析了 pickle 的源码,并且对于 缺失类也提供了一些解决方案。 背景 struct Byte order pickle.dumps 发生了什么? p...

torch.save 和 torch.load 默认使用的 pickle 模块进行序列化和反序列化。在调用 torch.load 时偶尔会遇到缺失类的问题。这篇文章仔细分析了 pickle 的源码,并且对于 缺失类也提供了一些解决方案。 背景 struct Byte order pickle.dumps 发生了什么? p...

Jinja2 is a fast, expressive, extensible templating engine. This blog records the problems or requirements I met during my development. Basic usage Use strings as templates Use ...

项目中的服务使用 tornado 来搭建,但是对于 tornado 如何启动还没有仔细研究过。 在某次问题排查时,仔细研究了 tornado 是如何启动的。 测试 刨根问底 最终代码 get_event_loop stop 总结 在 tornado 的大部分文档是建议使用 from tornado.ioloop imp...

在项目中使用比较多的 kubernetes。主要使用相应的 python kubernetes 库包来进行各种部署的管理。 国内很多讲解 kubernetes 原理,但是对于这个库各种使用看起来比较少。 Initialization Deployments 重启 deployment (patch_xxx) Service and ingr...

An email sent from bwg told me that my service had been banned due to a DDoS attack. My response is to change all the related passwords of the control pane and root user. But how to stop the futur...

A logger is preferred in a formal project, because we can set different levels for different loggers, redirect log messages to files (even to remote servers), specify a unified format for logs and ...

最近在工作中使用 python 开发时经常需要将多个 iterator 进行一些操作。以前的惯用手法要么是主动 使用 for 循环,要么是使用 zip 将多个 iterator 打平成多个。其实一直知道 itertools 这个库 的,只是偶尔会用,并没有去仔细研究过。 合并多个文件 合并多个文件 2 间隔取行 Block iterator 其它内容 ...

在开发的过程中,我们时常需要创建一些临时目录或者临时文件来保存一些状态。在 python 中一般 会使用 tempfile 这个模块。之前其实一直都是利用它的 gettempdir 来获取一个临时目录,然后在 临时目录中创建文件,最后在清理掉。实际上 tempfile 可以更加的智能。 gettempdir TemporaryFile NamedTemporaryFile ...

TMux is really awesome when you want to run commands on servers. But due to all kinds of reasons, you may lose the connection. If you reconnect to the same session, everything magically restores. ...

I am using coc-pywright to jump to the definition for programming in python. I have set it up to open a vertically split window. Sometimes I just want to keep current buffer in order to fully sprea...