Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
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
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
b57173cc
Commit
b57173cc
authored
Nov 05, 2021
by
Ophir LOJKINE
Committed by
oroulet
Nov 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
50% speedup in serialization of ua payloads with a timestamp
parent
5f99b3c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
22 deletions
+7
-22
asyncua/ua/uatypes.py
asyncua/ua/uatypes.py
+7
-22
No files found.
asyncua/ua/uatypes.py
View file @
b57173cc
...
@@ -7,11 +7,10 @@ from typing import Optional, Any, Union, Generic
...
@@ -7,11 +7,10 @@ from typing import Optional, Any, Union, Generic
import
collections
import
collections
import
logging
import
logging
from
enum
import
Enum
,
IntEnum
from
enum
import
Enum
,
IntEnum
from
calendar
import
timegm
import
uuid
import
uuid
import
re
import
re
import
itertools
import
itertools
from
datetime
import
datetime
,
timedelta
,
MAXYEAR
,
t
zinfo
from
datetime
import
datetime
,
timedelta
,
MAXYEAR
,
t
imezone
from
dataclasses
import
dataclass
,
field
from
dataclasses
import
dataclass
,
field
# hack to support python < 3.8
# hack to support python < 3.8
...
@@ -43,6 +42,7 @@ logger = logging.getLogger(__name__)
...
@@ -43,6 +42,7 @@ logger = logging.getLogger(__name__)
EPOCH_AS_FILETIME
=
116444736000000000
# January 1, 1970 as MS file time
EPOCH_AS_FILETIME
=
116444736000000000
# January 1, 1970 as MS file time
HUNDREDS_OF_NANOSECONDS
=
10000000
HUNDREDS_OF_NANOSECONDS
=
10000000
FILETIME_EPOCH_AS_DATETIME
=
datetime
(
1601
,
1
,
1
)
FILETIME_EPOCH_AS_DATETIME
=
datetime
(
1601
,
1
,
1
)
FILETIME_EPOCH_AS_UTC_DATETIME
=
FILETIME_EPOCH_AS_DATETIME
.
replace
(
tzinfo
=
timezone
.
utc
)
def
type_is_union
(
uatype
):
def
type_is_union
(
uatype
):
...
@@ -149,27 +149,12 @@ class Guid(uuid.UUID):
...
@@ -149,27 +149,12 @@ class Guid(uuid.UUID):
pass
pass
class
UTC
(
tzinfo
):
_microsecond
=
timedelta
(
microseconds
=
1
)
"""
UTC
"""
def
utcoffset
(
self
,
dt
):
return
timedelta
(
0
)
def
tzname
(
self
,
dt
):
return
"UTC"
def
dst
(
self
,
dt
):
return
timedelta
(
0
)
def
datetime_to_win_epoch
(
dt
:
datetime
):
def
datetime_to_win_epoch
(
dt
:
datetime
):
"""method copied from David Buxton <david@gasmark6.com> sample code"""
ref
=
FILETIME_EPOCH_AS_DATETIME
if
dt
.
tzinfo
is
None
else
FILETIME_EPOCH_AS_UTC_DATETIME
if
(
dt
.
tzinfo
is
None
)
or
(
dt
.
tzinfo
.
utcoffset
(
dt
)
is
None
):
return
10
*
((
dt
-
ref
)
//
_microsecond
)
dt
=
dt
.
replace
(
tzinfo
=
UTC
())
ft
=
EPOCH_AS_FILETIME
+
(
timegm
(
dt
.
timetuple
())
*
HUNDREDS_OF_NANOSECONDS
)
return
ft
+
(
dt
.
microsecond
*
10
)
def
get_win_epoch
():
def
get_win_epoch
():
...
@@ -777,7 +762,7 @@ class VariantTypeCustom:
...
@@ -777,7 +762,7 @@ class VariantTypeCustom:
def __eq__(self, other):
def __eq__(self, other):
return isinstance(other, type(self)) and self.value == other.value
return isinstance(other, type(self)) and self.value == other.value
def __hash__(self) -> int:
def __hash__(self) -> int:
return self.value.__hash__()
return self.value.__hash__()
...
@@ -830,7 +815,7 @@ class Variant:
...
@@ -830,7 +815,7 @@ class Variant:
VariantType.String,
VariantType.String,
VariantType.DateTime,
VariantType.DateTime,
VariantType.ExtensionObject,
VariantType.ExtensionObject,
):
):
raise UaError(
raise UaError(
f"
Non
array
Variant
of
type
{
self
.
VariantType
}
cannot
have
value
None
"
f"
Non
array
Variant
of
type
{
self
.
VariantType
}
cannot
have
value
None
"
)
)
...
...
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