Skip to content

Conversation

@takluyver
Copy link
Contributor

Struct.to_binary, Struct.parse_value and Struct.parse_binary were doing code generation to produce and store a specialised method for each struct instance. Apparently (see #12) this was a necessary optimisation in the distant past, but it's almost certainly no longer needed, and it makes the code considerably harder to follow.

On my machine the tests run slightly but noticeably faster with this change, but of course the tests are probably not a realistic sample for performance testing.

This doesn't directly impact Python 3 support, but it simplifies things.

Struct.to_binary, Struct.parse_value and Struct.parse_binary were doing
code generation to produce and store a specialised method for each
struct instance. Apparently (see python-xlib#12) this was a necessary optimisation
in the distant past, but it's almost certainly no longer needed, and it
makes the code considerably harder to follow.

On my machine the tests run slightly but noticeably faster with this
change, but of course the tests are probably not a realistic sample for
performance testing.

This doesn't directly impact Python 3 support, but it simplifies things.
@codecov-io
Copy link

Current coverage is 88.19%

Merging #13 into master will decrease coverage by -0.61% as of 177bab2

@@            master     #13   diff @@
======================================
  Files           10      10       
  Stmts         1876    1847    -29
  Branches         0       0       
  Methods          0       0       
======================================
- Hit           1666    1629    -37
  Partial          0       0       
- Missed         210     218     +8

Review entire Coverage Diff as of 177bab2

Powered by Codecov. Updated on successful CI builds.

@petli
Copy link
Contributor

petli commented Feb 18, 2016

That was quick turnaround!

Does the tests perform repeated packs/unpacks of the same structure? If it tests each struct a single time, it makes sense that this code runs slightly faster since it saves on the code generation.

@takluyver
Copy link
Contributor Author

I haven't written any new tests, and I guess that the existing tests are dominated by handling each kind of struct only once, so they're definitely not representative. I would definitely expect there to be some performance hit when using the same structs repeatedly. Are any of the examples in the repo likely to be useful for performance testing?

@petli
Copy link
Contributor

petli commented Feb 18, 2016

draw.py and shapewin.py might be candidates, as they are interactive.

@takluyver
Copy link
Contributor Author

Wouldn't a non-interactive example be a better candidate? I'm playing with draw.py a bit, but any variation in what it does is dominated by variation in the user activity, so I'm not sure how to get any comparable numbers out of it.

@vasily-v-ryabov
Copy link
Collaborator

I also vote for simplicity in this code. If there are no objections, I'm going to merge it tomorrow.

vasily-v-ryabov added a commit that referenced this pull request Feb 24, 2016
Eliminate code generation for Struct methods
@vasily-v-ryabov vasily-v-ryabov merged commit 2445b6e into python-xlib:master Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants