C++ vs. Python API Discrepancies has been created by Jonathan Robie (Mar 09, 2009).

Content:

This page compares C++ and Python code samples from our examples, looking for arbitrary discrepancies in the API. I suggest that we add proposals to fix these discrepancies inline for each example.

h2Opening and closing connections and sessions[/h2]

h3C++[/h3]

<pre>
Connection connection;
try

Unknown macro: { connection.open(host, port); Session session = connection.newSession(); ... connection.close(); return 0; }
catch(const std::exception& error)
Unknown macro: { std}

return 1;
</pre>

h3Python[/h3]

<pre>
host="127.0.0.1"
port=5672
user="guest"
password="guest"

socket = connect(host, port)
connection = Connection (sock=socket, username=user, password=password)
connection.start()
session = connection.session(str(uuid4()))
...
session.close(timeout=10)
</pre>

h3Discrepancies[/h3]

ulist

  • Python uses a socket object, not needed in the C++ API. I suggest that Python follow C++ here.
  • Python requires the user to provide a UUID instead of creating one for him. I suggest that Python provide the UUID automagically, as does C++.
  • Our Python examples end by closing the session, our C++ examples end by closing the connection. If both APIs allow both approaches, we should fix the examples; if not, we should make the APIs consistent.
    [/ulist]

--------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[email protected]

Reply via email to