Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
ad2e08df
Commit
ad2e08df
authored
Oct 05, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add simpler implementations of p64() and u64() for Python 2.2.
parent
eabb0131
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
24 deletions
+42
-24
src/ZODB/utils.py
src/ZODB/utils.py
+42
-24
No files found.
src/ZODB/utils.py
View file @
ad2e08df
...
...
@@ -83,11 +83,29 @@
#
##############################################################################
import
sys
import
TimeStamp
,
time
,
struct
t32
=
1L
<<
32
if
sys
.
version
>=
(
2
,
2
):
def
p64
(
v
,
pack
=
struct
.
pack
):
# Note that the distinction between ints and longs is blurred in
# Python 2.2. So make u64() and U64() the same.
def
p64
(
v
,
pack
=
struct
.
pack
):
"""Pack an integer or long into a 8-byte string"""
return
pack
(
">Q"
,
v
)
def
u64
(
v
,
unpack
=
struct
.
unpack
):
"""Unpack an 8-byte string into a 64-bit long integer."""
return
unpack
(
">Q"
,
v
)[
0
]
U64
=
u64
else
:
t32
=
1L
<<
32
def
p64
(
v
,
pack
=
struct
.
pack
):
"""Pack an integer or long into a 8-byte string"""
if
v
<
t32
:
h
=
0
...
...
@@ -95,8 +113,8 @@ def p64(v, pack=struct.pack):
h
,
v
=
divmod
(
v
,
t32
)
return
pack
(
">II"
,
h
,
v
)
def
u64
(
v
,
unpack
=
struct
.
unpack
):
"""Unpack an 8-byte string into a 64-bit (or long) integer
"""
def
u64
(
v
,
unpack
=
struct
.
unpack
):
"""Unpack an 8-byte string into a 64-bit (or long) integer.
"""
h
,
v
=
unpack
(
">ii"
,
v
)
if
v
<
0
:
v
=
t32
+
v
...
...
@@ -106,7 +124,7 @@ def u64(v, unpack=struct.unpack):
v
=
(
long
(
h
)
<<
32
)
+
v
return
v
def
U64
(
v
,
unpack
=
struct
.
unpack
):
def
U64
(
v
,
unpack
=
struct
.
unpack
):
"""Same as u64 but always returns a long."""
h
,
v
=
unpack
(
">II"
,
v
)
if
h
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment