
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Cheap Strings is a simple gem that makes it convenient to use frozen strings in your code.
Since Ruby strings are mutable, every string literal must allocate a new string whenever it is evaluated. Often this is a waste of time, as most strings in Ruby programs are never mutated.
Cheap Strings freezes your string literals and then reuses the same object every time - making your program faster and reducing GC pressure by not creating huge amounts of objects.
The benchmarks below use this common setup code:
require "cheap_strings"
module A
extend CheapStrings
def self.create_lots_of_strings
1_000_000.times do
"hello world"
end
end
def self.create_lots_of_cheap_strings
1_000_000.times do
`hello world`
end
end
end
require "benchmark"
Benchmark.bmbm do |b|
b.report "regular strings" do
A.create_lots_of_strings
end
b.report "cheap strings" do
A.create_lots_of_cheap_strings
end
end
Results:
Rehearsal ---------------------------------------------------
regular strings 0.240000 0.000000 0.240000 ( 0.242331)
cheap strings 0.140000 0.000000 0.140000 ( 0.135519)
------------------------------------------ total: 0.380000sec
user system total real
regular strings 0.240000 0.000000 0.240000 ( 0.235980)
cheap strings 0.140000 0.000000 0.140000 ( 0.139030)
def object_bench(name)
before, after = {}, {}
GC.start
GC.disable
ObjectSpace.count_objects(before)
yield
ObjectSpace.count_objects(after)
GC.enable
printf "%20s %6d -> %6d (+%8d)\n", name, before[:T_STRING], after[:T_STRING], after[:T_STRING] - before[:T_STRING]
end
object_bench "regular strings" do
A.create_lots_of_strings
end
object_bench "cheap strings" do
A.create_lots_of_cheap_strings
end
Results:
regular strings 5629 -> 1005655 (+ 1000026)
cheap strings 5657 -> 5657 (+ 0)
FAQs
Unknown package
We found that cheap_strings demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.