“内置方法解码”是什么意思? Python 分析时是什么意思?

发布于 2024-08-02 16:36:26 字数 197 浏览 5 评论 0 原文

我试图让我的程序更快,所以我正在对其进行分析。现在最重要的原因是:

566    1.780    0.003    1.780    0.003 (built-in method decode)

这到底是什么?我从来没有在代码中的任何地方调用“解码”。它读取文本文件,但我不相信它们是 unicode 编码的。

I'm trying to make my program faster, so I'm profiling it. Right now the top reason is:

566    1.780    0.003    1.780    0.003 (built-in method decode)

What is this exactly? I never call 'decode' anywhere in my code. It reads text files, but I don't believe they are unicode-encoded.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

离线来电— 2024-08-09 16:36:27

(回答 @Claudiu 的最新问题,奇怪地隐藏在评论中...?!-)...要真正加快酸洗速度,请尝试 空载燕子——其大部分雄心勃勃的目标仍有待实现,但它确实已经在酸洗和反酸洗方面提供了至少 20-25% 的加速。

(Answering @Claudiu's latest question, weirdly hidden in a commennt...?!-)... To really speed up pickling, try unladen swallow -- most of its ambitious targets are still to come, but it DOES already give at least 20-25% speedup in pickling and unpickling.

情定在深秋 2024-08-09 16:36:27

大概这是 str.decode ...在源代码中搜索“decode”。如果它不在您的代码中,请查看配置文件结果中显示的 Python 库例程。它不太可能与 cPickle 有关。愿意向我们展示更多一些“原因”(最好是列标题),以便我们更广泛地了解您的问题吗?

您能解释一下“使用 cPickle”和“某些测试用例会运行得更快”之间的联系吗?

您将 X 和 Y 排除在“有什么东西可以比资源 Y 更快地完成任务 X 吗?” ... 更新所以你问的是cPickle。 cPickle.dump() 和/或 cPickle.dumps() 的(可选)协议参数使用什么?

Presumably this is str.decode ... search your source for "decode". If it's not in your code, look at Python library routines that show up in the profile results. It's highly unlikely to be to be anything to do with cPickle. Care to show us a few more "reasons", preferably with the column headings, to give us a wider view of your problem?

Can you explain the connection between "using cPickle" and "some test cases would run faster"?

You left the X and Y out of "Is there anything that will do task X faster than resource Y?" ... Update so you were asking about cPickle. What are you using for the (optional) protocol arg of cPickle.dump() and/or cPickle.dumps() ?

最偏执的依靠 2024-08-09 16:36:27

我相信只要将 unicode 字符串转换为 ascii 字符串,decode 就会被调用。我猜你有大量的 unicode 数据。我不确定 pickle 的内部结构是如何工作的,但听起来 unicode 数据在 pickle 时会转换为 ascii ?

I believe decode is called anytime you are converting unicode strings into ascii strings. I am guessing you have a large amount of unicode data. I'm not sure how the internals of pickle work, but it sounds like that unicode data gets converted to ascii when pickled?

沫尐诺 2024-08-09 16:36:26

最有可能的是,这是字符串对象的解码方法

Most likely, this is the decode method of string objects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文