问题标签 [space-efficiency]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
23 浏览

python - 为什么 python 的数组对无符号整数使用 2 个字节,而 C 通常需要 4 个字节?

我需要存储大量无符号整数。查看 https://docs.python.org/3/library/array.html,我想知道为什么 python 的数组对无符号整数使用 2 个字节,而 C 语言通常需要 4 个字节?

0 投票
1 回答
58 浏览

functional-programming - 长度函数的尾递归版本是否在运行时节省了堆栈空间?

我被要求将此 F#length函数更改为尾递归函数。

虽然这不是一个困难的练习,但我想知道是否更改为尾递归版本,例如下面的那个,

与非尾递归相比,确实在运行时节省了堆栈空间?

0 投票
2 回答
43 浏览

mysql - 为什么 MySQL 更喜欢 ENUM('N','Y') 而不是 BOOL?

今天我注意到mysql默认 MySQL 8 安装中的数据库表使用了ENUM('N','Y')我期望它们使用的类型BOOL。例如,查看 的输出DESCRIBE user。其他地方也遵循相同的模式,例如db表格。

他们为什么要设计这样的桌子?我是否也应该在自己的表中使用枚举而不是布尔值?

0 投票
0 回答
22 浏览

python - 将多个 parquet 存储的数据帧合并为一个的节省空间的方法

我有几个包含数据帧(具有相同列)的镶木地板文件,我想将它们连接成一个巨大的熊猫数据帧。我能想到的最节省空间的解决方案是:

有没有更节省空间的解决方案?我愿意牺牲时间效率来换取空间效率。

0 投票
1 回答
91 浏览

sql - 关于SQL和NoSQL如何管理存储的问题

我是 NoSQL 的新手。我一直有这个问题。众所周知,在 SQL 中,数据存储在表中,除了第一行之外,只有数据。相比之下,NoSQL 将数据存储在 Object 中,其中至少包含一对 key-value。NoSQL 是否将每个文档的所有键重复存储在存储中?如果是这样,我可以肯定SQL在存储效率方面优于NoSQL吗?

这里的 NoSQL,我的意思是 MongoDB。对困惑感到抱歉。

0 投票
1 回答
70 浏览

arrays - Efficiency of Arrays vs Ranges in Ruby

While working on something recently, I started to think about the efficiency of Arrays and Ranges in Ruby. I started to try and research this but could find very little information on it or even how I could test this myself.

So I came across some code that checks what range a HTTP status code is in, and it's written something like this

So this got me thinking that it seems wasteful to use 200...300 when we essentially only need 200...207, but would there a big efficiency difference in this, if any at all?

Also what about the 4XX codes, as it is not always a straight run of the range, it got me thinking that maybe I should turn it into an array, so I could write it one of two ways

As a straight range CLIENT_ERROR = (400...429)

or as an array CLIENT_ERROR = [*(400...419), 422, 429]

I'm assuming the first option is a better approach and more efficient but just not too sure how to validate my thoughts, so any advice or input on this would be greatly appreciated