Skip to content

Commit cf647d5

Browse files
It's offer a very small performance gain
The original implementation from PyMySQL test instance type before. https://github.com/PyMySQL/PyMySQL/blob/3be54819ee6b09710be892a2b86f4592eaabf412/pymysql/util.py It's not require and by dropping it's a little faster.
1 parent 93be38b commit cf647d5

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

pymysqlreplication/event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import struct
44
import datetime
55

6-
from pymysql.util import byte2int, int2byte
6+
from .util import byte2int, int2byte
77

88

99
class BinLogEvent(object):

pymysqlreplication/packet.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import struct
44

5-
from pymysql.util import byte2int
65

76
from pymysqlreplication import constants, event, row_event
7+
from .util import byte2int
88

99
# Constants from PyMYSQL source code
1010
NULL_COLUMN = 251

pymysqlreplication/row_event.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import decimal
55
import datetime
66

7-
from pymysql.util import byte2int
8-
7+
from .util import byte2int
98
from .event import BinLogEvent
109
from .constants import FIELD_TYPE
1110
from .constants import BINLOG
@@ -497,7 +496,7 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection):
497496
for i in range(0, len(column_types)):
498497
column_type = column_types[i]
499498
column_schema = self.column_schemas[i]
500-
col = Column(byte2int(column_type), column_schema, from_packet)
499+
col = Column(column_type, column_schema, from_packet)
501500
self.columns.append(col)
502501

503502
self.table_obj = Table(self.column_schemas, self.table_id, self.schema,

pymysqlreplication/util.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import struct
2+
3+
def byte2int(b):
4+
return struct.unpack("!B", b)[0]
5+
6+
def int2byte(i):
7+
return struct.pack("!B", i)

0 commit comments

Comments
 (0)