如何在 django 中对位数组进行建模?

发布于 2024-11-14 06:40:38 字数 207 浏览 9 评论 0原文

在 django 模型(mysql 后端)中存储大型位数组的最佳方法是什么?

例如,我如何存储这个对象:

import bitarray
bits = bitarray.bitarray('11000101010') #real data is 35k bits long

我应该将它推入 CharField 中吗?

What would be the best way to store a large bitarray within a django model (mysql backend)?

for example, how could i store this object:

import bitarray
bits = bitarray.bitarray('11000101010') #real data is 35k bits long

Should i just shove it in a CharField?

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

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

发布评论

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

评论(1

意中人 2024-11-21 06:40:38

MySQL 有一个值得考虑的 BLOB 字段类型。

或者您可以将其转换为十六进制字符串,以长度为前缀,这将占用不到 9KB:

"11,C54"

或 ASCII-85,这将占用比十六进制更少的空间。

MySQL has a BLOB field type that's worth considering.

Or you could converting it to a hex string, prefixed with the length, which would take up less than 9KB:

"11,C54"

Or ASCII-85, which would take up less space than hex.

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