On Wed, Aug 23, 2017 at 5:02 AM 'Nathaniel Manista' via grpc.io <
[email protected]> wrote:

> [email protected]
>
> On Tue, Aug 22, 2017 at 6:06 AM, Amit Saha <[email protected]> wrote:
>
>> Hey all,
>>
>> Consider the sample .proto file:
>>
>>
>> ```
>> syntax = "proto3";
>>
>> // The greeting service definition.
>> service Greeter {
>>   // Sends a greeting
>>   rpc SayHello (HelloRequest) returns (HelloReply) {}
>>   // Sends another greeting
>>   rpc SayHelloAgain (HelloRequest) returns (HelloReply) {}
>> }
>>
>> // The request message containing the user's name.
>> message HelloRequest {
>>   string name = 1;
>> }
>>
>> // The response message containing the greetings
>> message HelloReply {
>>   string message = 1;
>> }
>> ```
>>
>> When I generate the client and server:
>>
>> ```
>> $ python -m grpc_tools.protoc -I../protos --python_out=.
>> --grpc_python_out=. ../protos/service.proto
>> ```
>>
>> The filenames are service_pb2.py   and   service_pb2_grpc.py. Should I
>> not be expecting `pb3` in the filenames consider I am declaring the syntax
>> to be proto3?
>>
>> Relevant packages + versions:
>>
>> ```
>> $ pip list
>> grpcio (1.4.0)
>> grpcio-tools (1.4.0)
>> protobuf (3.4.0)
>> setuptools (28.8.0)
>> ```
>>
>
> This is a Protocol Buffers thing much more than it is a gRPC thing, and I
> could be wrong about the reason, but my impression is that the "2" in
> "_pb2.py" (and thus in "_pb2_grpc.py", because we on the gRPC side just
> wanted to match what was being done on the Protocol Buffers side) denotes
> the *API version of the generated Python code*, not the .proto syntax
> version and also not the Protocol Buffers implementation version.
>
> There may not be much available documentation about API version 1 of the
> generated Python code (files ending in "_pb.py") because it was a long time
> ago. Also because it may only have ever been Google-internal.
> Generated-Python-code API Version 2 is definitely much better.
>
> Protocol Buffers Team, please confirm/correct this account?
> -Nathaniel (gRPC Python developer; not authoritatively knowledgable about
> Protocol Buffers Python)
>

Thanks Nataniel (and my apologies for posting it to the gRPC group). I took
 your clue and ended up on:
https://developers.google.com/protocol-buffers/docs/reference/python-generated
where
it's stated that:

The number 2 in the extension _pb2.py designates version 2 of Protocol
> Buffers. Version 1 was used primarily inside Google, though you might be
> able to find parts of it included in other Python code that was released
> before Protocol Buffers. Since version 2 of Python Protocol Buffers has a
> completely different interface, and since Python does not have compile-time
> type checking to catch mistakes, we chose to make the version number be a
> prominent part of generated Python file names. Currently both proto2 and
> proto3 use _pb2.py for their generated files.
>

That's my answer.

Thank you.

Best Wishes,
Amit.


>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "grpc.io" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/grpc-io/smY3vi8kY1I/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/grpc-io/CAEOYnAS6j%3DzEYtzVSN5WnLix1H0gxbZbhpOLW2K3%3D25L2eM4Ow%40mail.gmail.com
> <https://groups.google.com/d/msgid/grpc-io/CAEOYnAS6j%3DzEYtzVSN5WnLix1H0gxbZbhpOLW2K3%3D25L2eM4Ow%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CANODV3nekPyR%3DgeUscu296_Sz5mJoN%2Bky80eJnwWLzgy05KNyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to