Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Remove python <2.7,<3.3 string/unicode workarounds #8832

Merged
merged 6 commits into from
Mar 25, 2017

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Mar 25, 2017

This transforms strings to use the u and b prefixes for unicode and bytes:

  • asbytes('hello')b'hello'
  • asbytes_nested(['a', 'b'])[b'a', b'b']
  • asunicode('hello')u'hello'
  • unicode('hello')u'hello'
  • sixu('hello')u'hello'

This is fine because b is supported on 2.7 and 3.x, and u is supported on 2.x and 3.3+. Our minimum versions are now 2.7 and 3.4?

What we can't do is transform asbytes("tests %d" % num), because %-formatting
fails on bytes in python 3.x < 3.5.

As a result, asunicode and sixu are now not used anywhere.

Since we only need to support python 2, we can remove any case where we just
pass a single string literal and use the b prefix instead.

What we can't do is transform asbytes("tests %d" % num), because %-formatting
fails on bytes in python 3.x < 3.5.
@eric-wieser eric-wieser changed the title MAINT: Remove asbytes where a b prefix would suffice MAINT: Remove python <2.7,<3.3 string/unicode workarounds Mar 25, 2017
@eric-wieser eric-wieser added the component: numpy.ma masked arrays label Mar 25, 2017
@eric-wieser eric-wieser force-pushed the avoid-as-bytes branch 2 times, most recently from c340754 to 6ad2ce7 Compare March 25, 2017 11:56
@juliantaylor
Copy link
Contributor

thanks, nice cleanup
though seeing this used so often just reminds me of the poor state our io functions are in...

@eric-wieser
Copy link
Member Author

eric-wieser commented Mar 25, 2017

though seeing this used so often just reminds me of the poor state our io functions are in

Tell me about it. Perhaps now that we don't use these conversion/hack functions much in testing, they can give a deprecation warning on python 3?

@eric-wieser
Copy link
Member Author

Also, is removing functions from numpy.compat ok, or is that public api?

@juliantaylor
Copy link
Contributor

technically public api, we could slap deprecation warnings on them but I don't think its worth the effort.

@eric-wieser
Copy link
Member Author

eric-wieser commented Apr 10, 2017

Hmmm... This had a big performance hit on bench_core.CountNonzero.time_count_nonzero(1, 1000000, <type 'str'>), which is a little surprising.

Especially since none of the things this touches should have any effect on the behaviour of count_nonzero...

@eric-wieser
Copy link
Member Author

eric-wieser commented Apr 10, 2017

Ah, that regression is clearly from 9791f20, and is due to a deliberate benchmark change.

@pv: Am I reading ASV incorrectly, or does it look like there's a bug in attaching commit ids to benchmarks?

@pv
Copy link
Member

pv commented Apr 10, 2017 via email

@eric-wieser
Copy link
Member Author

eric-wieser commented Apr 10, 2017

ASV does not try to track if the benchmark code itself is changed

Sure, that explains why the regression is there. But why does it attach the regression to this commit, and not to your commit? It has benchmark data for both, and mine came before yours!

On a related note, does this mean this was a bad merge, and the benchmark should have been renamed to avoid creating these false regressions?

@pv
Copy link
Member

pv commented Apr 10, 2017 via email

@eric-wieser
Copy link
Member Author

eric-wieser commented Apr 10, 2017

Gotcha, that clarifies things

Does this mean that if a pull request introduces a benchmark and a fix, that the benchmark will be tested on the previous commit as well?

Or did that only happen in this case because the two commits were merged on the same day?

@pv
Copy link
Member

pv commented Apr 10, 2017 via email

@juliantaylor
Copy link
Contributor

automatic invalidation worked pretty well in the vbench suite. It took the checksum of the benchmark and invalided the results when it changed.

@pv
Copy link
Member

pv commented Apr 10, 2017 via email

@pv
Copy link
Member

pv commented Apr 10, 2017 via email

@eric-wieser
Copy link
Member Author

Perhaps a simple "version" field in benchmarks would do the job too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants