bytestring
Fast, compact, strict and lazy byte strings with a list interface
https://github.com/haskell/bytestring
Version on this page: | 0.12.1.0 |
LTS Haskell 22.41: | 0.11.5.3 |
Stackage Nightly 2024-11-12: | 0.12.1.0 |
Latest on Hackage: | 0.12.1.0@rev:1 |
bytestring-0.12.1.0@sha256:361dd394d22115d6b1cdc040c12b071eba9f7689d8953d8cc2ed6f55f5670252,8973
Module documentation for 0.12.1.0
ByteString: Fast, Packed Strings of Bytes
This library provides the Data.ByteString
module – strict and lazy
byte arrays manipulable as strings – providing very time/space-efficient
string and IO operations.
For very large data requirements, or constraints on heap size,
Data.ByteString.Lazy
is provided, a lazy list of bytestring chunks.
Efficient processing of multi-gigabyte data can be achieved this way.
The library also provides Data.ByteString.Builder
for efficient construction
of ByteString
values from smaller pieces during binary serialization.
Requirements:
- Cabal 1.10 or greater
- GHC 8.0 or greater
Authors
ByteString
was derived from the GHC PackedString
library,
originally written by Bryan O’Sullivan, and then by Simon Marlow.
It was adapted and greatly extended for darcs by David Roundy and
others. Don Stewart and Duncan Coutts cleaned up and further extended
the implementation and added the .Lazy
code. Simon Meier contributed
the Builder
feature.
Changes
0.12.1.0 — February 2024
- Provisional support has been added for using
bytestring
with GHC’s JavaScript back-end.- This support is relatively un-tested and un-optimised. There may be bugs! Please report any you discover to
bytestring
’s issue tracker. - The JavaScript back-end’s limited support for the Haskell-C foreign function interface would previously result in many operations failing with errors like
ReferenceError: h$fps_count is not defined
. - The new
pure-haskell
package flag allows the new fallback Haskell implementations (used to support the JavaScript backend) to be used on most other platforms as well.
- This support is relatively un-tested and un-optimised. There may be bugs! Please report any you discover to
- Bug fixes:
stimes 0 sbs :: ShortByteString
now returns the emptyShortByteString
instead of throwing an exceptionstimes 0 b :: Builder
now returns the emptyBuilder
instead of throwing an exception- Several alignment-related bug fixes
- Fix a bug in
isValidUtf8
sconcat @ShortByteString
is no longer terribly inefficient- Fix the type on the foreign import used for
Data.ByteString.Short.elemIndex
- Ensure that the result of
fromShort
is protected bymkDeferredByteString
- Behavior changes:
- The
Data.Data.Data
instances forStrictByteString
andLazyByteString
have been changed:toConstr
now returns the apack
pseudo-constructor instead of throwing an exception.- Due to this pseudo-constructor,
gunfold
can now be meaningfully used at these types. (Previously, it would always raise an exception.) - These changes allow
syb:Data.Generics.Text.gshow
to be meaningfully used at types containingByteString
s.
- A derived
instance Generic ShortByteString
has been added. sconcat @Builder
is now lazy in the tail of its input
- The
- Deprecations:
- Performance improvements:
- Various raw-binary
Builder
primitives likeintHost
orword32BE
are much less inefficient on architectures not known to support unaligned writes. (1, 2) - Hexadecimal encoding suffers one indirection fewer
Data.ByteString.Lazy.takeEnd
is somewhat fasterData.ByteString.Lazy.dropEnd
is much faster
- Various raw-binary
- Miscellaneous:
- Various documentation improvements (1, 2, 3, 4, 5)
- Eta-expand
Data.ByteString.Builder.Internal.empty
- This can variously help or hurt performance; it undoes the performance changes caused by CLC proposal 132 with ghc-9.8 and restores the baseline performance seen with older GHCs.
0.12.0.2 — August 2023
0.12.0.1 — August 2023
0.12.0.0 — July 2023
- Breaking Changes:
readInt
returnsNothing
, if the sequence of digits cannot be represented by anInt
, instead of overflowing silently- Remove
zipWith
rewrite rule ShortByteString
is now a wrapper aroundData.Array.Byte.ByteArray
instead ofByteArray#
directly- As a compatibility measure,
SBS
remains available as a pattern synonym. - The compatibility package
data-array-byte
is used whenbase
does not provideData.Array.Byte
.
- As a compatibility measure,
fromListN
frominstance IsList ShortByteString
now throws an exception if the first argument does not match the length of the second- Previously, it would ignore the first argument entirely.
- Bug fixes:
- Size-related calculations are more resistant to
Int
overflow in the following places:
- Size-related calculations are more resistant to
- API additions:
- Deprecations:
Data.ByteString.getLine
: preferData.ByteString.Char8.getLine
Data.ByteString.hGetLine
: preferData.ByteString.Char8.hGetLine
0.11.5.3 — October 2023
- Bug fixes:
0.11.5.2 — August 2023
0.11.5.1 — August 2023
0.11.5.0 — July 2023
- Bug fixes:
- API additions:
- Deprecations:
Data.ByteString.Internal.memcpy
: preferForeign.Marshal.Utils.copyBytes
Data.ByteString.Internal.memset
: preferForeign.Marshal.Utils.fillBytes
- Performance improvements:
- Miscellaneous:
0.11.4.0 — January 2023
- Bug fixes:
- API additions and behavior changes:
- Performance improvements:
- Miscellaneous:
0.11.3.1 — May 2022
- Windows: Do not link against
gcc_s
- Windows: Do not link against
gcc
when GHC >= 9.4 - Refine CPP for obsolete versions of
gcc
0.11.3.0 — February 2022
Erratum: unsafeIndex
was accidentally removed from the export list of Data.ByteString.Short.Internal
in this release. This was corrected in 0.11.4.0.
- Enhance
ShortByteString
API- Add
all
,any
,append
,break
,breakEnd
,breakSubstring
,concat
,cons
,count
,drop
,dropEnd
,dropWhile
,dropWhileEnd
,elem
,elemIndex
,elemIndices
,filter
,find
,findIndex
,findIndices
,foldl'
,foldl
,foldl1'
,foldl1
,foldr'
,foldr
,foldr1'
,foldr1
,head
,init
,intercalate
,isInfixOf
,isPrefixOf
,isSuffixOf
,last
,map
,partition
,replicate
,reverse
,singleton
,snoc
,span
,spanEnd
,split
,splitAt
,splitWith
,stripPrefix
,stripSuffix
,tail
,take
,takeEnd
,takeWhile
,takeWhileEnd
,uncons
,unfoldr
,unfoldrN
,unsnoc
toData.ByteString.Short
.
- Add
- Add
Data.ByteString.Short.isValidUtf8
- Use safe
isValidUtf8
for large inputs - Make
unlines
lazier - Improve performance of
unlines
- Make
singleton
return a slice of a static buffer - Improve performance of
intercalate
0.11.2.0 — December 2021
- Add
Data.ByteString.isValidUtf8
- Speed up
floatDec
anddoubleDec
using the Ryu algorithmData.ByteString.Builder.RealFloat
offers additional custom formatters for floating point numbers.
- Add
StrictByteString
andLazyByteString
type aliases - Add
foldr'
,foldr1'
,scanl1
,scanr
,scanr1
toData.ByteString.Lazy{,.Char8}
- Add
takeEnd
,dropEnd
,takeWhileEnd
,dropWhileEnd
,spanEnd
,breakEnd
toData.ByteString.Lazy{,.Char8}
- Add
Data.ByteString.Builder.writeFile
to writeBuilder
to file directly - Add
Data.ByteString.{from,to}FilePath
for encoding-aware conversions - Add
Lift
instances for all flavors ofByteString
- Add
HasCallStack
for partial functions - Define
foldl
,foldl'
,foldr
,foldr'
,mapAccumL
,mapAccumR
,scanl
,scanr
andfilter
with one argument less to allow more inlining - Speed up internal loop in
unfoldrN
- Speed up
count
with SSE and AVX instructions - Improve performance of certain
Builder
s by using a static table for Base16 - Use
unsafeWithForeignPtr
whenever possible - Remove
integer-simple
flag - Remove misleading mentions of fusion
0.11.1.0 — February 2021
- Add
Data.ByteString.Char8.findIndexEnd
andData.ByteString.Lazy.Char8.{elemIndexEnd,findIndexEnd,unzip}
- Expose
ShortByteString
constructor fromData.ByteString.Short
- Add
compareLength
function, which is lazier than comparison of lengths - Add strict
takeEnd
anddropEnd
- Expose
packZipWith
to zip twoByteString
- Add
instance Show Builder
- Improve lazy
pack
to carry fewer arguments in the inner loop - Improve
map
,findIndex
andfindIndexEnd
to carry fewer arguments in the inner loop - Improve lazy
{take,drop}While
,break
andgroup{,By}
to carry fewer arguments in the inner loop - Speed up
intersperse
using SSE2 instructions fromShort
does not reallocate its argument, if it is pinned- Speed up
words
using a faster test for spaces - Implement
stimes
more efficiently than default definition
0.10.12.1 – January 2021
0.11.0.0 — September 2020
- Change internal representation of
ByteString
, removing offset- The old
PS
constructor has been turned into a pattern synonym that is available with GHC >= 8.0 for backwards compatibility. Consider addingif !impl(ghc >=8.0) { build-depends: bytestring < 0.11 }
to packages, which usePS
and still support GHC < 8.0.
- The old
- Fill
ForeignPtrContents
ofnullForeignPtr
withFinalPtr
instead of a bottom - Remove deprecated functions
findSubstring
andfindSubstrings
- Speed up sorting of short strings
- Improve handling of literal strings in
Data.ByteString.Builder
- Compute length at compile time for literal strings
- This improves optimization opportunities for functions that scrutinize the length of a
ByteString
.
- This improves optimization opportunities for functions that scrutinize the length of a
- Add
indexMaybe
and synonym(!?)
for indexing that returnsMaybe
- Add rewrite rules for
{take,drop}While ({=,/}= x)
- Add rewrite rules for
any (== x)
andall (/= x)
- Add rewrite rules for
findInd{ex,ices} (== x)
- Improve folds to pass fewer arguments on each recursive invocation
- Improve performance of
findIndices
- Re-export
Data.ByteString.Lazy.{from,to}Strict
fromData.ByteString
- Remove deprecated modules and functions
- Use
Data.ByteString.Builder{,.Extra}
instead ofData.ByteString.Lazy.Builder{,.ASCII,.Extras}
. - Use
Data.ByteString.Char8.{,h}putStrLn
instead ofData.ByteString.{,h}putStrLn
andData.ByteString.Lazy.Char8.putStrLn
instead ofData.ByteString.Char8.putStrLn
. - Use
Data.ByteString.break (== x)
instead ofData.ByteString.breakByte x
. - Use
Data.ByteString.Internal.accursedUnutterablePerformIO
instead ofData.ByteString.Internal.inlinePerformIO
.
- Use
0.10.12.0 – August 2020
- Note: There are several breaking changes planned to be included in v0.11. Please ensure that your packages have appropriate upper bounds on bytestring, in order to minimize avoidable breakage.
- Add
takeWhileEnd
anddropWhileEnd
toData.ByteString
andData.ByteString.Char8
, and adddropSpace
andstrip
toData.ByteString.Char8
- Add
findIndexEnd
toData.ByteString
andData.ByteString.Lazy
- Add
partition
toData.ByteString.Char8
andData.ByteString.Lazy.Char8
- Add
IsList
instances for strict and lazyByteString
and forShortByteString
- Add
createUptoN'
andunsafeCreateUptoN'
toData.ByteString.Internal
- Add
boundedPrim
toData.ByteString.Builder.Prim.Internal
and deprecateboudedPrim
- Deprecate the
Data.ByteString.Lazy.Builder
andData.ByteString.Lazy.Builder.{ASCII,Extras}
modules - Fix documented complexity of
Data.ByteString.Lazy.length
- Assorted documentation fixes
0.10.10.1 – June 2020
- Fix off-by-one infinite loop in primMapByteStringBounded (#203)
- Don’t perform unaligned writes when it isn’t known to be safe (#133)
- Improve the performance of sconcat for lazy and strict bytestrings (#142)
- Document inadvertent 0.10.6.0 behaviour change in findSubstrings
- Fix benchmark builds (#52)
- Documentation fixes
- Test fixes
0.10.10.0 July 2019 [email protected] July 2019
- Build with GHC 8.8, and tests with QC 2.10+
- Add conversions between ShortByteString and CString (#126)
- Documentation fixes (#65, #118, #144, #150, #152, #172)
- Resolve potential copyright issue with test data (#165)
0.10.8.2 Duncan Coutts [email protected] Feb 2017
- Make readFile work for files with no size like /dev/null
- Extend the cases in which concat and toStrict can avoid copying data
- Fix building with ghc-7.0
- Minor documentation improvements
- Internal code cleanups
0.10.8.1 Duncan Coutts [email protected] May 2016
- Fix Builder output on big-endian architectures
- Fix building with ghc-7.6 and older
0.10.8.0 Duncan Coutts [email protected] May 2016
- Use Rabin-Karp substring search for
breakSubstring
andfindSubstring
- Improve the performance of
partition
for lazy and strict bytestrings - Added
stripPrefix
andstripSuffix
for lazy and strict bytestrings - Fix building with ghc 8.0 & base 4.9 (Semigroup etc)
0.10.6.0 Duncan Coutts [email protected] Mar 2015
- Rename inlinePerformIO so people don’t misuse it
- Fix a corner case in unfoldrN
- Export isSuffixOf from D.B.Lazy.Char8
- Add D.B.Lazy.elemIndexEnd
- Fix readFile for files with incorrectly reported file size
- Fix for builder performance with ghc 7.10
- Fix building with ghc 6.12
0.10.4.1 Duncan Coutts [email protected] Nov 2014
- Fix integer overflow in concatenation functions
- Fix strictness of lazy bytestring foldl’
- Numerous minor documentation fixes
- Various testsuite improvements