A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-January/041583.html below:

[Python-Dev] SF patch 864863: Bisect C implementation

[Python-Dev] SF patch 864863: Bisect C implementation [Python-Dev] SF patch 864863: Bisect C implementationGuido van Rossum guido at python.org
Fri Jan 2 10:59:41 EST 2004
> I think that something like:
> 
> <heapq.py>
> heapq python code...
> 
> try:
>    from _heapq import * # or list the names explicitly
> except ImportError:
>    pass
> </heapq.py>
> 
> can be made to work.

I like this too.

> The tricky part is more in test_heapq, but I think it can be rewritten in 
> some form like:
> 
> import heapq # import likely the C code
> test(heapq) # or heapq could be a global
> heapq = test.support.get_pure_python_version(heapq)
> test(heapq)
> 
> or some variation.

Note that you could force the _heapq import to fail by putting an
explicit None in sys.modules, like so:

  import heapq
  ...test the C impl...
  sys.modules['_heapq'] = None
  reload(heapq) # Now 'from _heapq import ...' will fail
  ...test the Python impl...
  # Restore the default situation
  del sys.modules['_heapq']
  reload(heapq)

I wish cStringIO and cPickle would go away, but unfortunately the
Python versions have features that the C code don't have.  Hopefully
the use of new-style classes can avoid this issue for new module pairs.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4