compact_str
smartstring
compact_str | smartstring | |
---|---|---|
16 | 7 | |
541 | 482 | |
- | - | |
7.6 | 0.0 | |
4 days ago | 8 months ago | |
Rust | Rust | |
MIT License | Mozilla Public License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
compact_str
-
Announcing `compact_str` version 0.7! A small string optimization for Rust
Not that I know of! As part of compact_str v0.6 we tried to make the API of CompactString 1:1 with String, inevitably we missed a few (1, 2, 3) things but they were fixed in this latest release.
... and more! Please see the CHANGELOG for more detail
-
Is there a type like `std::num::NonZero*` but for other values than zero?
(See the compact_str implementation as an example.)
-
Announcing `compact_str` version 0.6! A small string optimization for Rust
Along with performance improvements, this release includes implementing multiple methods for CompactString, to bring its API nearly 1:1 with String. The only exception being methods that don't have a direct port for a small string optimization, e.g. into_bytes, or methods that aren't yet stable. A full change log can be found here.
- What is Box and how is it different from String in Rust?
-
Announcing `compact_str` version 0.5! A small string optimization for Rust
Doing this has been on the back of my mind for a while, just filed an issue to track this! #119
-
Announcing `compact_str` version 0.4! A small string optimization for Rust
There's a draft pr for this.
-
Why is it so hard to get traction learning rust?
Here're a few projects I considered interesting (including my own project) and relatively easy to participate: - pushgen Push-style design pattern for processing of ranges and data-streams. - compact_str A memory efficient immutable string type that can store up to 24* bytes on the stack - openssh-rs Scriptable SSH through OpenSSH in Rust - pegasus A multi-node parametrized command runner with a focus on simplicity - concurrent_arena Container that can have elements insert/removed concurrently and uses a 'u32' as key.
-
Inlined string (in ~200 LOC)
I wrote something similar to compact_str, but it is: - a Box when on the heap - (so clone is O(n)) - (but still immutable) - 2 usizes in size
-
Is there any other programming language aside from C++ that has move semantics feature available?
Here you go: https://github.com/ParkMyCar/compact_str
smartstring
-
Does using "String" instead of "&str" a lot results in unoptimised code?
Your use case sounds like it will involve a lot of small strings that use a subset of UTF-8. If you’re concerned about performance, you could look into something like smartstring. Sixbit also looks interesting, but it looks like it won’t give you any more characters and it’d probably require additional computation to do the conversion (and they’d have to be converted back out).
-
Rust Is Hard, Or: The Misery of Mainstream Programming
> If you have a long-running async function, then pass parameters by value! If you have a polymorphic async function, then return your result in a Box.
I've taken to making heavy use of the smallvec and smartstring crates for this. Most lists and strings are small in practice. Using smallvec / smartstring lets you keep most clone() calls allocation-free. This in turn lets you use owned objects, which are easier to reason about - for you and the borrow checker. And you keep a lot of the performance of just passing around references.
I tried to use async rust a couple of years ago, and fell on my face in the process. Most of my rust at the moment is designed to compile to wasm - and then I'm leaning on nodejs for networking and IO. Writing async networked code is oh so much easier to reason about in javascript. When GAT, TAIT and some other language features to fix async land I'll muster up the courage to make another attempt. But rust's progress at fixing these problems feels painfully slow.
https://crates.io/crates/smallvec / https://crates.io/crates/smartstring
-
GitHub - epage/string-benchmarks-rs: Comparison of Rust string types
Just to point out, smartstring no longer assumes String memory layout. From the changelog:
-
Why is str not just [char]?
There's some really good crates that implement SSO floating around - eg, SmartString. But I agree - its a pity they're needed. Swift built this into the core string type in the language. I think that was the right call.
-
Announcing `compact_str`! A super memory efficient immutable string that is transparently stored on the stack, when possible
Comparatively: * SmolStr can inline up to 22 bytes but does not adjust down for 32-bit architectures, meaning it's potentially wasting memory on 32-bit archs. Similarly though it's immutable and Clone is O(1) * SmartString can inline up to 23 bytes, but it's mutable and Clone is O(n). Also this crate makes assumptions about the memory layout of a String, which in theory should be fine, but is a slight caveat.
-
Version 0.19.15 released.
SmartString is used to store identifiers (which tends to be short, fewer than 23 characters, and ASCII-based) because they can usually be stored inline. Map keys now also use SmartString.
-
Speed of Rust vs. C
I’ve been using smartstrings, which is both excellent and maintained. https://github.com/bodil/smartstring
What are some alternatives?
DIPs - D Improvement Proposals
smol_str
min-sized-rust - 🦀 How to minimize Rust binary size 📦
openssh - Scriptable SSH through OpenSSH in Rust
libskry_r - Lucky imaging library
zero-copy-pads - Padding/aligning values without heap allocation
bitter - Extract bits from a byte slice
rust - Empowering everyone to build reliable and efficient software.
redgrep - ♥ Janusz Brzozowski
perf-ninja-rs - Rust port of dendibakh/perf-ninja - an online course where you can learn and master the skill of low-level performance analysis and tuning.
fst - Represent large sets and maps compactly with finite state transducers.